• Sun. Oct 24th, 2021
    • Introduction: The robot will move forward, backward, right and left anywhere and if that place supposes a table and when it will come near to an edge the robot will automatically sense the edge by the help of IR sensor and it will give impulse to Arduino to handle the rotation of the DC motors by initiating motor driver to act accordingly as per the logic implemented in the code uploaded in Arduino UNO.
    • Materials:
      • Arduino UNO
      • Two IR Sensor
      • L293D Motor Driver
      • Battery (Power Bank)
      • Jumper Wires
      • Two DC Motors
      • One Chassis
      • Caster Wheels
      • Mini Bradboard
    • How to Make:
    IR Sensor Connection
    • We have two IR sensors module
    • Left IR sensor and Right IR sensor which has
    • VCC is connected to +5v
    • GND is connected to GND
    • OP connect to pin of Arduino UNO
    L293D Connection to Arduino
    • L293D ic has 16 pin… 1,8,9 and 16 pin connect to +5v. And 4,5,12,13 pin connect to GND…
    • Input 1,2,3 and 4 pin is connect to Arduino pin.
    • The output needs to be connected to left motor and right motor.
    • Input 1 and 2 is connect for left motor.
    • And input 3 and 4 is connect for right motor.
    Circuit Diagram
    • Two IR Sensors:
      • Left IR sensor op means output pin connects to the 9 pin of Arduino
      • Right IR sensor output pin connected to the 12 pin of Arduino
      • Two IR sensor’s VCC connect to +5v
      • And GND connect to GND
    • L293D Motor Driver:
      • 8 pin of Arduino connect to 2 pin of L293D
      • 7 pin of Arduino connect to 7 pin of L293D
      • 4 pin of Arduino connect to 10 pin of L293D
      • 3 pin of Arduino connect to 15 pin of L293D
      • VCC is connected to +5v
      • And GND is connected to GND to the 9v battery

    Code:

    #define LS 9 // left sensor
    #define RS 12 // right sensor
    /*-------definning Outputs------*/
    #define LM1 8 // left motor
    #define LM2 7 // left motor
    #define RM1 4 // right motor
    #define RM2 3 // right motor
    void setup()
    {
    pinMode(LS, INPUT);
    pinMode(RS, INPUT);
    pinMode(LM1, OUTPUT);
    pinMode(LM2, OUTPUT);
    pinMode(RM1, OUTPUT);
    pinMode(RM2, OUTPUT);
    }
    void loop()
    {
    if(digitalRead(LS) && digitalRead(RS))
    // Move Forward
    {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
    }
    if(!(digitalRead(LS)) && digitalRead(RS)) // Turn right
    { digitalWrite(LM1, LOW);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
    }
    if(digitalRead(LS) && !(digitalRead(RS)))
    // turn left { digitalWrite(LM1, LOW);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
    }
    if(!(digitalRead(LS)) && !(digitalRead(RS)))
    // stop
    {
    digitalWrite(LM1, LOW);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, LOW);
    digitalWrite(RM2, LOW);
    }
    }
    

    And Here You Go….

    Leave a Reply

    Your email address will not be published. Required fields are marked *