Tinker CAD Obstacle Avoiding Robot

Introduction: Tinker CAD Obstacle Avoiding Robot

Hi guys!! Check out this obstacle avoiding robot. It is very simple to do this, just collect all the components and start working on it. This was made with Tinker CAD circuits.

Supplies

Materials needed:

*Arduino UNO or Nano

*Ultrasonic Sensor

*Motor driver

*Two BO motors, with wheels

*Battery

*Breadboard

Step 1: Connections

Start connecting the materials as shown in the circuit diagram. Connect them with jumper cables or solder them. Use a 9-volt battery to run the project, you can either connect the battery with the dc jack in Arduino or connect to 5v and GND pins.

Step 2: Coding

Its easier to code, just download the Arduino IDE software in your pc or laptop and connect the A to B coding Cable and start coding.

Code:

int trigPin = 9; // trig pin of HC-SR04int

echoPin = 10; // Echo pin of HC-SR04
int revleft4 = 4; //REVerse motion of Left motorint

fwdleft5 = 5; //ForWarD motion of Left

motorint revright6 = 6; //REVerse motion of Right motorint

fwdright7 = 7; //ForWarD motion of Right motor long duration, distance;

void setup()

{ delay(random(500,2000)); // delay for random time

Serial.begin(9600);

pinMode(revleft4, OUTPUT); // set Motor pins as output

pinMode(fwdleft5, OUTPUT);

pinMode(revright6, OUTPUT);

pinMode(fwdright7, OUTPUT);

pinMode(trigPin, OUTPUT); // set trig pin as output

pinMode(echoPin, INPUT); //set echo pin as input to capture reflected waves}

void loop()

{ digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH); // send waves for 10 us

delayMicroseconds(10);

duration = pulseIn(echoPin, HIGH); // receive reflected waves

distance = duration / 58.2; // convert to distance delay(10); // If you dont get proper movements of your robot then alter the pin numbers

if (distance > 19)

{ digitalWrite(fwdright7, HIGH); // move forward

digitalWrite(revright6, LOW);

digitalWrite(fwdleft5, HIGH);

digitalWrite(revleft4, LOW);

}

if (distance < 18)

{ digitalWrite(fwdright7, LOW); //Stop

digitalWrite(revright6, LOW);

digitalWrite(fwdleft5, LOW);

digitalWrite(revleft4, LOW);

delay(500);

digitalWrite(fwdright7, LOW); //movebackword

digitalWrite(revright6, HIGH);

digitalWrite(fwdleft5, LOW);

digitalWrite(revleft4, HIGH);

delay(500);

digitalWrite(fwdright7, LOW); //Stop

digitalWrite(revright6, LOW);

digitalWrite(fwdleft5, LOW);

digitalWrite(revleft4, LOW);

delay(100);

digitalWrite(fwdright7, HIGH);

digitalWrite(revright6, LOW);

digitalWrite(revleft4, LOW);

digitalWrite(fwdleft5, LOW);

delay(500);

}

}

Step 3: Tutorial

Arduino Contest 2020

Participated in the
Arduino Contest 2020

Be the First to Share

    Recommendations

    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Tinkercad Student Design Contest

      Tinkercad Student Design Contest
    • Plastic Challenge

      Plastic Challenge

    Comments