Servo motor controlling using IoT.
Servo motor rotating angle can be controlled using NodeMCU And android app(Blynk).
Required components
- NodeMCU.
- Servo motor.
- power supply(you can use USB cable).
Schematic
Result video
Code
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
char auth[] = "YOUR Blynk AUTH CODE";
char ssid[] = "YOUR WIFI NAME";
char pass[] = "YOUR WIFI PASSWORD";
BlynkTimer timer;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
myservo.attach(D2);//Servo motor connecting pin,You can change pin but be sure about PWM availabilty on that pin.
}
void loop()
{
Blynk.run();
timer.run();
}
BLYNK_WRITE(V1)
{
int x = param[0].asInt();
int y = param[1].asInt();
Serial.print("X = ");
Serial.print(x);
Serial.print("; Y = ");
Serial.println(y);
if (x <= 0 && y < 600)
{
myservo.write(180);//left
}
else if (x == 1023 && y > 400) //right
{
myservo.write(0);
}
else if (x == 512 && y == 512) //stop
{
myservo.write(90);
}
else
{
myservo.write(90);
}
}
Hi. Very happy to see your projects. Please update Blynk app configuration video for servo control
ReplyDeleteI want to make a car with servo steering.... How to control 1 servo and 1 dc mini motor with blynk app... I have nodemcu, mechanical setup, L298n, blynk app
ReplyDelete