
/*
 * Joystick pe V0 si Vi split
 * servo pini GPIO 13 si GPIO 33
 * comanda leduri pe GPIO 12, 14, 27
 * cu butoane pe D12, 14, 27 fara definitie
 * */
 #include <ESP32Servo.h>
Servo Servo1;
Servo Servo2;

int servo1 = 1023/2; //initial position of the servo 1
int angle1;
int servo2=1023/2;  //initial position of the servo 2
int angle2; 

static const int ServoPin1 = 13; 
static const int ServoPin2 = 33; 

//#include <SPI.h>

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char auth[] = "e5beac0d31f4433da82dc64b99a03b39"; 
char ssid[] = "UPCF4821BC";
char pass[] = "Gherla1956";

void setup(){
  Serial.begin(115200);
Servo1.attach(ServoPin1);
Servo2.attach(ServoPin2);
//SPI.begin();
    Blynk.begin(auth, ssid, pass);
}

BLYNK_WRITE(V0) 
{
  servo1 = param.asInt();
}

BLYNK_WRITE(V1) 
{
  servo2 = param.asInt();
}
  
void loop()
{
Blynk.run(); 
  angle1 = map(servo1, 0, 1023, 0, 180); 
  angle2 = map(servo2, 0, 1023, 0, 180); 
Servo1.write(angle1); 
Servo2.write(angle2); 
  }
