BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

App says device is online but wont control project

#I have followed the instrctions perfect I am new to this please help In the app it says device is online but #the joystick does nothing I have tried 4 aa baterries and a 9v battery. I hope I posted this right.

#this is the name of the project I found online

Simplest Wifi Car Using ESP8266 Motorshield

#define BLYNK_PRINT Serial 
#include  <ESP8266WiFi.h>
#include  <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App. 
// Go to the Project Settings (nut icon). 
char auth[] = "YourAuthToken"; 

// Your WiFi credentials. 
// Set password to "" for open networks. 
char ssid[] = "YourNetworkName"; 
char pass[] = "YourPassword"; 

int PWMA=5;//Right side 
int PWMB=4;//Left side 
int DA=0;//Right reverse 
int DB=2;//Left reverse 

void setup(){ 
 // Debug console 
 Serial.begin(9600); 
 Blynk.begin(auth, ssid, pass); 
 pinMode(PWMA, OUTPUT); 
 pinMode(PWMB, OUTPUT); 
 pinMode(DA, OUTPUT); 
 pinMode(DB, OUTPUT); 
} 

void loop(){ 
Blynk.run(); 
  
} 

// Handling Joystick data 
BLYNK_WRITE(V1){ 
int x = param[0].asInt(); 
int y = param[1].asInt();  
if(x==-1 && y==-1){             //Backward and Left     
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, HIGH); 
}else if(x==-1 && y==0){        //Left Turn 
     digitalWrite(PWMA, 450); 
     digitalWrite(DA, HIGH); 
    
     digitalWrite(PWMB, 450); 
     digitalWrite(DB, LOW); 
}else if(x==-1 && y==1){        //Forward and Left     
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
    
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, LOW); 
}else if(x==0 && y==-1){        //Backward     
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, HIGH); 
     
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, HIGH);
}else if(x==0 && y==0){        //Stay 
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW); 
}else if(x==0 && y==1){        //Forward 
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, LOW); 
    
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, LOW); 
}else if(x==1 && y==-1){        //Backward and Right     
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, HIGH); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW); 
}else if(x==1 && y==0){        //Right turn 
     digitalWrite(PWMA, 450); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, 450); 
     digitalWrite(DB, HIGH); 
}else if(x==1 && y==1){        //Forward and Right 
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW);
 } 
} 

void loop()

In the app, is your joystick widget set to Split or Merge?
Which virtual pin(s) is the joystick attached to?

Pete.

It is set to Merge not sure how to to verify virtual pin?

Steve

Pete

Wow, I never saw that, when I get back to it this morning I will post an update.

Thanks I am sure that has to be it.

Steve

Now the blue light on the esp goes out (but motors do not spin) when I go right or reverse but not left of forward I have tested my motors and tried swapping wiring as well. Progress!

Steve

The “2” in the code above means GPIO Pin 2. This is not the same as the pin that’s labelled “D2” on the board. The Blue LED on the board is connected to GPIO2 and is active (lit) when the pin is pulled LOW.

See this diagram for the mapping of GPIO numbers to pin labels:

You should also read this topic about “safe” pins to use:

Pete.

I am not sure if this makes a difference but I am using this Motor Shield…Screenshot_2020-04-20 Simplest wifi car using ESP8266 Motorshield

I’m not familiar with that shield, so I can’t comment, but it seems the code was written for it and published in an Instructable, so I guess it’s fine.

Have you double-checked the widget settings in the app are EXACTLY like this:

Pete.

Yes I checked all of that. Thank you for your time and input, I have sent a message to the original designer just waiting for a reply. My actual goal it to make a car with our without a raspberry pi 3 and camera that my grand children can control form the house thru the internet some way like the website remo.tv. Any Advice?

Steve

FYI, I have a topic about using the Joystick to control a rover… I just updated my code so feel free to glean from it.

Thank you.