DIY Arduino Obstacle-Avoidance Robot Made
by 703826 in Circuits > Arduino
183 Views, 1 Favorites, 0 Comments
DIY Arduino Obstacle-Avoidance Robot Made
![IMG_4099 (1).jpg](/proxy/?url=https://content.instructables.com/FU5/YCM3/LRRSPFXV/FU5YCM3LRRSPFXV.jpg&filename=IMG_4099 (1).jpg)
In this Intractable, I will guide you through the process of building a Arduino-based obstacle-avoidance robot. This robotic platform uses an Arduino Uno, an ultrasonic sensor, DC motors, and an L293d motor driver to navigate and avoid obstacles in its path.
Supplies
![IMG_4097.jpg](/proxy/?url=https://content.instructables.com/FI9/KONE/LRRSPDNM/FI9KONELRRSPDNM.jpg&filename=IMG_4097.jpg)
![IMG_4100.jpg](/proxy/?url=https://content.instructables.com/F0A/6TNI/LRRSPDOO/F0A6TNILRRSPDOO.jpg&filename=IMG_4100.jpg)
![IMG_4096.jpg](/proxy/?url=https://content.instructables.com/FR2/WP7R/LRRSPDOT/FR2WP7RLRRSPDOT.jpg&filename=IMG_4096.jpg)
![IMG_4099.jpg](/proxy/?url=https://content.instructables.com/FP6/9HAZ/LRRSPDOZ/FP69HAZLRRSPDOZ.jpg&filename=IMG_4099.jpg)
Materials:
- Arduino Uno
- Ultrasonic sensor
- 2 x DC motors
- L293d motor driver
- 9V battery
- Caster ball
- Motor wheels
(for the Multi vibrator)
- 2- LED's
- 2 - NPN
- 4 - 330 Resistors
- 2 - 10v 100nf capacitors
Fixing Motors and Motor Drivers to the Chassis (if Not Already )
![IMG_4103 (1).jpg](/proxy/?url=https://content.instructables.com/F9J/WVWC/LRRSPDX7/F9JWVWCLRRSPDX7.jpg&filename=IMG_4103 (1).jpg)
![IMG_4102.jpg](/proxy/?url=https://content.instructables.com/FZ3/0R5Y/LRRSPE6S/FZ30R5YLRRSPE6S.jpg&filename=IMG_4102.jpg)
- Fix the DC motors onto the chassis.
- Attach wheels to the shafts of the DC motors.
- Place the L293d motor driver on or below the chassis surface.
- Connect the motor driver: IN1 and IN2 to Arduino pins 4, 5, 2, and 3.
Fixing Ultrasonic Sensor
![IMG_4098.jpg](/proxy/?url=https://content.instructables.com/FSH/L90H/LRRSPF07/FSHL90HLRRSPF07.jpg&filename=IMG_4098.jpg)
- Connect VCC of the ultrasonic sensor to 5V on the Arduino.
- Connect GND of the ultrasonic sensor to GND on the Arduino.
- Connect TRIG of the ultrasonic sensor to Digital pin 9 on the Arduino.
- Connect ECHO of the ultrasonic sensor to Digital pin 8 on the Arduino.
Step 4: Connecting Power Supply
![IMG_4100 (1).jpg](/proxy/?url=https://content.instructables.com/F7M/133Q/LRRSPEY8/F7M133QLRRSPEY8.jpg&filename=IMG_4100 (1).jpg)
- Use a 9V battery for power.
- Connect the positive terminal of the battery to the VIN pin on the Arduino.
- Connect the negative terminal of the battery to the GND pin on the Arduino.
Step 5: Programming the Arduino
Upload the following Arduino code to control the movement of the chassis:
#define echopin 8 // echo pin
#define trigpin 9 // Trigger pin
int maximumRange = 30;
long duration, distance;
void setup() {
Serial.begin (9600);
pinMode (trigpin, OUTPUT);
pinMode (echopin, INPUT );
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT); } void loop () {
{
digitalWrite(trigpin,LOW);
delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
duration=pulseIn (echopin,HIGH);
distance= duration/58.2;
delay (50);
Serial.println(distance);
}
if (distance >= 30 ){
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
delay (200); }
else if (distance >=15 && distance <= 25) {
digitalWrite (2,HIGH);
digitalWrite (3,LOW);
digitalWrite (4,LOW);
digitalWrite (5,LOW);
delay (1000); }
else if (distance < 15){
digitalWrite (2, LOW);
digitalWrite (3, HIGH);
digitalWrite (4, LOW);
digitalWrite (5, HIGH);
delay (1000);
digitalWrite (2,LOW);
digitalWrite (3,LOW);
digitalWrite (4,HIGH);
digitalWrite (5,LOW);
delay (1000); }
}
Final Step
- Disconnect the Arduino from the computer.
- Connect the 9V battery to power the chassis.
- Observe the chassis' movement – it should move forward until it detects an obstacle within 10 cm.
Conclusion:
Congratulations! You've successfully built an Arduino-based obstacle-avoidance chassis. Feel free to customize the code and experiment with additional features. Enjoy your robotic creation!