Very new - trying to help a group of self-starting students who are exploring Blynk and tinkering with electronics for the first time. Sorry for my lack of knowledge and thank you for your patience.
We are building a robotic car using a NodeMCU 1.0 board with a ESP-12E Module on it. The code compiles fine and we have verified the board is connected to wifi.
We are using Blynk on an android phone connected to the same wifi. The buttons are all configured correctly, but the device is never found.
I have read the beginner information about keeping the void loop clean, etc. and can confirm that’s not the issue here. I also read someone discussing changing the ports to communicate with the server, but I’m not sure how to go about that or if it’s necessary given my setup. I was hoping to have a standalone setup where the app and device communicated through the wifi connection.
Below is my code (scrubbed of the auth token, ssid and password), Would love any feedback/help. Several students are growing frustrated as they have been working on this together for three days now with no progress.
Thanks again!
/**************************************************************
* This example runs directly on ESP8266 chip
* using the Blynk platform and mobile application.
*
* Change WiFi ssid, password, and Blynk auth token to run :)
*
**************************************************************/
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define RightMotorSpeed 5
#define RightMotorDir 0
#define LeftMotorSpeed 4
#define LeftMotorDir 2
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "redacted";
char ssid[] = "redacted";
char pass[] = "redacted";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(RightMotorSpeed, OUTPUT);
pinMode(RightMotorDir, OUTPUT);
pinMode(LeftMotorSpeed, OUTPUT);
pinMode(LeftMotorDir, OUTPUT);
}
void loop()
{
Blynk.run();
}
void halt()
{
digitalWrite(RightMotorSpeed, LOW);
digitalWrite(LeftMotorSpeed, LOW);
}
void forward()
{
digitalWrite(RightMotorDir, HIGH);
digitalWrite(LeftMotorDir, HIGH);
digitalWrite(RightMotorSpeed, HIGH);
digitalWrite(LeftMotorSpeed, HIGH);
}
void reverse()
{
digitalWrite(RightMotorDir, LOW);
digitalWrite(LeftMotorDir, LOW);
digitalWrite(RightMotorSpeed, HIGH);
digitalWrite(LeftMotorSpeed, HIGH);
}
void right()
{
digitalWrite(RightMotorDir, LOW);
digitalWrite(LeftMotorDir, HIGH);
digitalWrite(RightMotorSpeed, HIGH);
digitalWrite(LeftMotorSpeed, HIGH);
}
void left()
{
digitalWrite(RightMotorDir, HIGH);
digitalWrite(LeftMotorDir, LOW);
digitalWrite(RightMotorSpeed, HIGH);
digitalWrite(LeftMotorSpeed, HIGH);
}
BLYNK_WRITE(V0)
{
if (param[0])
forward();
else
halt();
}
BLYNK_WRITE(V1)
{
if (param[0])
reverse();
else
halt();
}
BLYNK_WRITE(V2)
{
if (param[0])
right();
else
halt();
}
BLYNK_WRITE(V3)
{
if (param[0])
left();
else
halt();
}