BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Trying out a blynk controlled car on a esp board. Having cconnection issues. Using a local server

Wemos d1 mini clone with wifi
Andriod
Local server
The joystick works okay. But drops connection making the car stuck on 1 command like “forward” for some time

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_TEMPLATE_ID "TMPLRIRidq5R"
#define BLYNK_DEVICE_NAME "Car"
#define BLYNK_AUTH_TOKEN ""
#define ipconfig ""
#define port 8080
#define leftMotor 5 // D3
#define rightMotor 14 //D4

int x=0;
int y=0;
int Speed;


char auth[] =  BLYNK_AUTH_TOKEN; //Enter your Blynk auth token
char ssid[] = "srh-welcome"; //Enter your WIFI name
char pass[] = ""; //Enter your WIFI passowrd



void setup() {
   pinMode(leftMotor, OUTPUT);
   pinMode(rightMotor, OUTPUT);
   digitalWrite(leftMotor, HIGH);
   digitalWrite(rightMotor, HIGH);
   Blynk.begin(auth, ssid, pass, ipconfig, 8080);
  }

BLYNK_WRITE(V0) {
  x = param[0].asInt();
  y = param[1].asInt();
}
  

//Get the slider values
BLYNK_WRITE(V2) {
  Speed = param.asInt();
}  
void car() {
  if (x==0 && y==0){
     stopda();
    }else
  if (y > 1) {
    forward();
    Serial.println("carForward");
  } else
  if (y < -1) {
    stopda();
    Serial.println("stop!");
  } else
  if (x < -1) {
    left();
    Serial.println("carLeft");
  } else
  if (x > 1) {
    right();
    Serial.println("carRight");
  } else
  if(y<=1 && y >=-1 && x>=-1 && x <=1) {
    stopda();
    Serial.println("carstop");
  } else{}
}
void loop() {
  Blynk.run();// Run the blynk function
  delay(100);
  car();// Call the main function
}



void forward(){
    digitalWrite(leftMotor,LOW);
    digitalWrite(rightMotor,LOW);
   }


 void left(){
   digitalWrite(leftMotor,HIGH);
   digitalWrite(rightMotor,LOW);
   }

 void right(){
   digitalWrite(leftMotor,LOW);
   digitalWrite(rightMotor,HIGH);
   }

  void stopda(){
    digitalWrite(leftMotor,HIGH);
    digitalWrite(rightMotor,HIGH);
   }

Simply paste your code between ``` If you don't format your code, your topic can be deleted by moderators.

@Verty Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard, do not use Blockquotes as you are at the moment.

Pete.

done ty

Are you really running a legacy local server. If you are, where have you obtained these values from?

You also need to read this…

https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

Pete.

i switched to a legacy server from the current one. Its leftover code will remove. Reading the documentation you linked now

Local server version? Blynk library version, app version?

Pete.

got it working. The motors were dropping below a critical voltage making the board stop working when 2 motors were running, causing disconnects

I’m interested in driving a car online. Remote controlled car is about to stand on wireless charger.