IOT Robot with NodeMCU and Arduino using Blynk.

Introduction:

Controlling robots wirelessly is great fun. There are many methods available through which you can control your robot wirelessly.
They are:
  1.  RF remote controller
  2.  Bluetooth signal
  3.  IR signal
  4.  Wifi or IOT etc...
Here I have made a project of robot controlled over IOT using blynk app,arduino and nodemcu.

Things needed

  • Arduino
  • Nodemcu(Esp8266)
  • 2 DC motors and Motor driver
  • LCD display(may or may not added)
  • Batteries or any other power source
  • Blynk Application 
  • Jumper wires etc.

Step 1: Building the Body of Robot

I Build the robot with Sun-board and card board gluing them with super glue. I used old mobile batteries as source and stick them to body. here are some pictures of my build.


Step 2: Connection of different elements

  • Connect two dc motors to the motor driver. for more about motor drivers follow this:https://www.ganeshgadgets.co.in/2017/09/line-follower-part-2-motor-driver.html
  • Connect arduino to the motor driver. use enable of motor driver with PWM inputs of arduino.
  • Power up nodemcu with arduino from 5v pin. Here the idea is when arduino receives digital output from nodemcu at its input pins it would do certain actions.
  • 5 outputs from nodemcu(D0-D4) is fed to 5 pins of arduino(A0 toA5 -here digital pins are used so pin 14 to pin 19).
  • Example when D0 of nodemcu is high, Arduino receives signal and command noter driver to go forward. 
Code example:
if ( digitalRead(a0) == HIGH ) //forward//
 {
  lcd.setCursor(0, 1);
  lcd.print("FORWARD ");
  digitalWrite(af, HIGH);
  digitalWrite(ar, LOW);
  digitalWrite(bf, HIGH);
  digitalWrite(br, LOW);
 }

                   Step 3: Programming Nodemcu and Arduino

                  Code:
                  #include <LiquidCrystal.h>
                  LiquidCrystal lcd(8, 9, 10, 11, 12, 13); //16x2 lcd interface

                  int en = 3;//a-right motor  b-Left motor //
                  int af = 6;int ar = 7;
                  int bf = 5;int br = 4;

                  int a0=14 , a1=15 , a2= 16 ,a3= 17, a4= 18;//from nodemcu D0 to D4//

                  void setup() {
                  lcd.begin(16, 2); 

                   pinMode(en,OUTPUT);
                   pinMode(ar,OUTPUT);pinMode(af,OUTPUT);
                   pinMode(bf,OUTPUT);pinMode(br,OUTPUT);

                   pinMode(a0,INPUT); pinMode(a1,INPUT); pinMode(a2,INPUT);
                   pinMode(a3,INPUT); pinMode(a4,INPUT);

                   digitalWrite(en,HIGH);
                  // loading();
                  }

                  void loop() {
                    
                    if ( digitalRead(a0) == HIGH ) //forward//
                   {
                    lcd.setCursor(0, 1);
                    lcd.print("FORWARD "); 
                    digitalWrite(af, HIGH);
                    digitalWrite(ar, LOW);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br, LOW);
                   }
                     if (digitalRead(a1) == HIGH) //backward//
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("BACKWARD"); 
                    digitalWrite(af, LOW);
                    digitalWrite(ar,HIGH);
                    digitalWrite(bf, LOW);
                    digitalWrite(br, HIGH);
                      }
                    if (digitalRead(a2) == HIGH)  //RIGHT
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("RIGHT     ");     
                    digitalWrite(af, LOW);
                    digitalWrite(ar,HIGH);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br,LOW);
                        } 
                    if (digitalRead(a3) == HIGH)//LEFT
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("LEFT      ");        
                    digitalWrite(af, HIGH);
                    digitalWrite(ar,LOW);
                    digitalWrite(bf, LOW);
                    digitalWrite(br, HIGH);
                      }
                    if (digitalRead(a4) == HIGH)//STOP
                      {
                    lcd.setCursor(0, 1);
                    lcd.print("STOP      ");        
                    digitalWrite(af, HIGH);
                    digitalWrite(ar, HIGH);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br, HIGH);
                      }  
                    else
                    {
                    lcd.setCursor(0, 1);
                    lcd.print("        ");          
                    digitalWrite(af, HIGH);
                    digitalWrite(ar, HIGH);
                    digitalWrite(bf, HIGH);
                    digitalWrite(br, HIGH);
                     }

                  Conclusion:

                  You can easily build this. you can add lights to the robot and also other features using nodemcu. here is working video of the robot.
                  https://youtu.be/UsY_pJP5PVc

                  Also like and subscribe the channel.

                  No comments:

                  Post a Comment