Hardware components | ||||||
| × | 1 | ||||
![]() |
| × | 1 | |||
| × | 2 | ||||
![]() |
| × | 1 | |||
Software apps and online services | ||||||
![]() |
| |||||
![]() |
|
In this video I'm gong to show you how to make Esp8266 based IOT Car using your blynk IOT cloud platform
Components1.NodeMcu
2.L298n motor module
3.5v Dc motors-2
4.Jumper wires
if you want to watch the full video version of the tutorial, watch it through my youtube channel.
Click here to make your hands full of dirty by doing lots of IOT and diy projects
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define RightMotorSpeed D5 //14
#define RightMotorDir D6 //12
#define LeftMotorSpeed D7 //13
#define LeftMotorDir D8 //15
char auth[] = "eJCH8Zkr3b4Pn17xRBl1kKEOAC_sVhnf"; //Blynk Authentication Token
char ssid[] = "ZTE WIFI"; //WIFI Name
char pass[] = "kl2229834"; //WIFI Password
int minRange = 312;
int maxRange = 712;
int minspeed = 450;
int maxspeed = 1020;
int nospeed = 0;
void moveControl(int x, int y)
{
//Move Forward
if(y >= maxRange && x >= minRange && x<= maxRange)
{
digitalWrite( RightMotorDir,HIGH);
digitalWrite(LeftMotorDir,HIGH);
analogWrite(RightMotorSpeed, maxspeed);
analogWrite(LeftMotorSpeed , maxspeed);
}
//Move Forward Right
else if(x >= maxRange && y >= maxRange)
{
digitalWrite( RightMotorDir, HIGH);
digitalWrite(LeftMotorDir,HIGH);
analogWrite(RightMotorSpeed,minspeed);
analogWrite(LeftMotorSpeed ,maxspeed);
}
//Move Forward Left
else if(x <= minRange && y >= maxRange)
{
digitalWrite( RightMotorDir,HIGH);
digitalWrite(LeftMotorDir,HIGH);
analogWrite(RightMotorSpeed,maxspeed);
analogWrite(LeftMotorSpeed ,minspeed);
}
//No Move
else if(y < maxRange && y > minRange && x < maxRange && x > minRange)
{
analogWrite(RightMotorSpeed,nospeed);
analogWrite(LeftMotorSpeed , nospeed);
}
//Move Backward
else if(y <= minRange && x >= minRange && x <= maxRange)
{
digitalWrite( RightMotorDir,LOW);
digitalWrite(LeftMotorDir,LOW);
analogWrite(RightMotorSpeed,maxspeed);
analogWrite(LeftMotorSpeed ,maxspeed);
}
//Move Backward Right
else if(y <= minRange && x <= minRange)
{
digitalWrite( RightMotorDir,LOW);
digitalWrite(LeftMotorDir,LOW);
analogWrite(RightMotorSpeed,minspeed);
analogWrite(LeftMotorSpeed ,maxspeed);
}
//Move Backward Left
else if(y <= minRange && x >= maxRange)
{
digitalWrite( RightMotorDir,LOW);
digitalWrite(LeftMotorDir,LOW);
analogWrite(RightMotorSpeed,maxspeed);
analogWrite(LeftMotorSpeed ,minspeed);
}
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(RightMotorSpeed, OUTPUT);
pinMode(LeftMotorSpeed , OUTPUT);
pinMode( RightMotorDir, OUTPUT);
pinMode(LeftMotorDir, OUTPUT);
digitalWrite(RightMotorSpeed, LOW);
digitalWrite(LeftMotorSpeed , LOW);
digitalWrite( RightMotorDir, HIGH);
digitalWrite(LeftMotorDir, HIGH);
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(V1)
{
int x = param[0].asInt();
int y = param[1].asInt();
moveControl(x,y);
}
Comments
Please log in or sign up to comment.