Change WiFi ssid, password, and Blynk auth token to run :)
**/
define BLYNK_PRINT Serial // Comment this out to disable prints and save space
include
include
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[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "MyWifi";
char pass[] = "MyWifiPassword";
Please add NodeMCU + Motor Shield sample
Source: https://surak.wordpress.com/2016/12/18/robot-car-controlled-by-iphone-using-blynk-and-nodemcu/
/**
define BLYNK_PRINT Serial // Comment this out to disable prints and save space
include
include
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[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; char ssid[] = "MyWifi"; char pass[] = "MyWifiPassword";
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(); }