Define BLYN1
Define BLYN1
Define BLYN1
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define trig D2
#define echo D1
long duration;
int distance;
BlynkTimer timer;
void sendSensor()
Serial.println(distance);
if(distance <= 5)
Blynk.tweet("My Arduino project is tweeting using @blynk_app and it’s awesome!\n #arduino
#IoT #blynk");
Blynk.virtualWrite(V0, distance);
int nospeed = 0;
//Move Forward
digitalWrite( RightMotorDir,HIGH);
digitalWrite(LeftMotorDir,HIGH);
analogWrite(RightMotorSpeed, maxspeed);
analogWrite(LeftMotorSpeed , maxspeed);
digitalWrite(LeftMotorDir,HIGH);
analogWrite(RightMotorSpeed,minspeed);
analogWrite(LeftMotorSpeed ,maxspeed);
}
//Move Forward Left
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);
digitalWrite( RightMotorDir,LOW);
digitalWrite(LeftMotorDir,LOW);
analogWrite(RightMotorSpeed,minspeed);
analogWrite(LeftMotorSpeed ,maxspeed);
digitalWrite( RightMotorDir,LOW);
digitalWrite(LeftMotorDir,LOW);
analogWrite(RightMotorSpeed,maxspeed);
analogWrite(LeftMotorSpeed ,minspeed);
void setup()
// Debug console
Serial.begin(9600);
pinMode(RightMotorSpeed, OUTPUT);
pinMode(LeftMotorSpeed , OUTPUT);
pinMode(LeftMotorDir, OUTPUT);
digitalWrite(RightMotorSpeed, LOW);
digitalWrite(LeftMotorSpeed , LOW);
digitalWrite( RightMotorDir, HIGH);
digitalWrite(LeftMotorDir, HIGH);
timer.setInterval(1000L, sendSensor);
void loop()
Blynk.run();
BLYNK_WRITE(V1)
int x = param[0].asInt();
int y = param[1].asInt();
moveControl(x,y);