OBSTACLE AVOIDING ROBOT CIRCUIT | TINKERCAD

by Advik Shettigar in Circuits > Arduino

442 Views, 0 Favorites, 0 Comments

OBSTACLE AVOIDING ROBOT CIRCUIT | TINKERCAD

OBSTACLE AVOIDING ROBOT CIRCUIT | TINKERCAD

In this article I will tell you the steps to make an obstacle avoiding robot circuit using TinkerCad. In this circuit my motors will be moving forward if there is no obstacle in less than 10cm and it will take a right turn if there is an obstacle in less than 10cm.

Step 1: Components Required

BREADBOARD.png
L293D-MOTR DRIVER.png
MOTORS.png
ARDUINO UNO R3.png
ULTRASONIC SENSOR.png

The required components to make this circuit are as follows:-

  • Breadboard
  • L293D - Motor Driver
  • Motors - 2 Nos.
  • Arduino UNO R3
  • Ultrasonic Distance Sensor

Step 2: Connections

CIRCUIT.png

Make the connections as shown in the above picture using TinkerCad Circuits.

Step 3: CodeBlocks/CodeText

CODE.png
CODE TEXT PART 1.jpg
CODE TEXT PART 2.jpg

Drag and drop the code blocks in the TinkerCad software.

// C++ code

//

long readUltrasonicDistance(int triggerPin, int echoPin)

{

 pinMode(triggerPin, OUTPUT); // Clear the trigger

 digitalWrite(triggerPin, LOW);

 delayMicroseconds(2);

 // Sets the trigger pin to HIGH state for 10 microseconds

 digitalWrite(triggerPin, HIGH);

 delayMicroseconds(10);

 digitalWrite(triggerPin, LOW);

 pinMode(echoPin, INPUT);

 // Reads the echo pin, and returns the sound wave travel time in microseconds

 return pulseIn(echoPin, HIGH);

}


void setup()

{

 pinMode(8, OUTPUT);

 pinMode(9, OUTPUT);

 pinMode(10, OUTPUT);

 pinMode(11, OUTPUT);

 pinMode(LED_BUILTIN, OUTPUT);

}


void loop()

{

 if (0.01723 * readUltrasonicDistance(7, 6) < 10) {

  digitalWrite(8, HIGH);

  digitalWrite(9, LOW);

  digitalWrite(10, LOW);

  digitalWrite(11, HIGH);

 } else {

  digitalWrite(8, HIGH);

  digitalWrite(9, LOW);

  digitalWrite(10, HIGH);

  digitalWrite(11, LOW);

 }


 digitalWrite(LED_BUILTIN, HIGH);

 delay(1000); // Wait for 1000 millisecond(s)

 digitalWrite(LED_BUILTIN, LOW);

 delay(1000); // Wait for 1000 millisecond(s)

}

Downloads