So I am making a football playing robot which consists of 3 servo motors. Currently,i am only checking only a single servo(myservoKicker)which is operated via button in the blynk app and trying to read x and y values from joysticks in blynk. I am using wifi communication. I have seen that wifi.begin never properly starts as the serial.print("Blynk Connected") after it does not run, plus on my blynk app the project constantly connects and disconnects. Note: The code for steering other servo's is not implemented yet and is just a stub. Board: DoIt ESP32 Devkit V1 30 GPIO Blynk: 0.6.1 myservoKicker connected to pin 13
#include <ESP32Servo.h>
#include <SPI.h>
#include <Ethernet.h>
#include <ETH.h>
#include <WiFi.h>
#include <WiFiAP.h>
#include <WiFiClient.h>
#include <WiFiGeneric.h>
#include <WiFiMulti.h>
#include <WiFiScan.h>
#include <WiFiServer.h>
#include <WiFiSTA.h>
#include <WiFiType.h>
#include <WiFiUdp.h>
#include <BlynkSimpleEsp32.h>
Servo myservoKICKER;
Servo myservoLEFTWHEEL;
Servo myservoRIGHTWHEEL;
int pos;
char auth[] = "9Itekdu3vf_B_3YmNxxHu9G3Bs_1IWs9";
char ssid[] = "RO IMRAN RO";
char pass[] = "xxxxxxxxxxx";
char localserver[16]= "192.168.1.1";
BLYNK_WRITE(V1)
{
int xAxis = param[0].asInt();
int yAxis = param[1].asInt();
// Do something with x and y
Serial.print("X = ");
Serial.print(xAxis);
Serial.print("; Y = ");
Serial.println(yAxis);
}
BLYNK_WRITE(V4){ //WHEEL CALIBRATION
int WheelCalibration=param.asInt();
if(WheelCalibration == 1)
{
myservoLEFTWHEEL.attach(26);
myservoRIGHTWHEEL.attach(27);
delay(100);
myservoLEFTWHEEL.write (90);
myservoRIGHTWHEEL.write (90);
delay(30000);
}
}
BLYNK_WRITE(V5){ //KICKER 90 DEGREE CALIBRATION
int KickerCalibration= param.asInt();
if(KickerCalibration == 1)
{
myservoKICKER.attach(13);
delay(100);
myservoKICKER.write (90);
delay(200);
}
}
void setup(){
// Attach servos to pins
myservoLEFTWHEEL.attach(26); //1
myservoRIGHTWHEEL.attach(27); //2
myservoKICKER.attach(13); //3
// detach servos to avoid jitter on power up
myservoLEFTWHEEL.detach();
myservoRIGHTWHEEL.detach();
myservoKICKER.detach();
Serial.begin(115200);
delay(10);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid,pass);
int wifi_ctr = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
Blynk.begin("9Itekdu3vf_B_3YmNxxHu9G3Bs_1IWs9",ssid,pass);
Serial.println("Blynk connected");
}
void loop()
{
Blynk.run();
}