Arduino Obstacle-Avoiding Robot

Arduino UNO 19-01-25
32 0

Tutorial plan

1- What is the Obstacle-Avoiding robot ?

2- Operation of Arduino Obstacle-Avoiding robot

3- Components needed

4- Wiring Configuration

5- Arduino program for the robot

 

What is the Obstacle-Avoiding robot ?

A robot avoiding obstacles refers to an autonomous or semi-autonomous system designed to navigate its environment while detecting and avoiding obstacles in its path. This is achieved using various sensors and algorithms that enable the robot to identify obstacles, calculate alternative paths, and move safely without collisions.

1. The robot continuously scans its surroundings using an ultrasonic sensor.

2. If an object is detected within a certain threshold distance (e.g., 20 cm):

The robot stops moving forward.

It turns left or right until the path is clear.

3. The robot resumes its forward motion once no obstacles are detected.

This principle is the foundation of many real-world robots and autonomous systems.

 

Operation of Arduino Obstacle-Avoiding robot

This project involves using an Arduino UNO, an L293D motor driver module, an HC-SR04 ultrasonic sensor, a servo motor, and a 2-wheel kit to build a robot that can navigate its environment while avoiding obstacles.

Working Principle:

1. Obstacle Detection Using the HC-SR04 Sensor:

The HC-SR04 emits ultrasonic waves when the Trig pin is triggered.

The sensor measures the time it takes for the ultrasonic waves to return after hitting an obstacle.

The Arduino calculates the distance

2. Scanning the Environment with the Servo Motor:

The servo motor rotates the ultrasonic sensor to scan the left, center, and right directions (e.g., at angles 0°, 90°, and 180°).

The Arduino reads the distance for each direction.

3. Decision Making:

Based on the distances measured in different directions:

If the center is clear, the robot moves forward.

If an obstacle is detected in the center:

- The robot scans the left and right distances.

- It turns towards the direction with the greater distance.

4. Motor Control via L293D:

The Arduino sends signals to the L293D to control the motors for forward, backward, left, and right movements:

- Forward: Left motor (clockwise), right motor (clockwise).

- Left Turn: Left motor (stopped), right motor (clockwise).

- Right Turn: Left motor (clockwise), right motor (stopped).

Components needed

Arduino UNO:

Arduino Uno

The main microcontroller that processes sensor input and controls the motors and servo.

L293D Motor Driver Module:

Controls the speed and direction of the two DC motors based on signals from the Arduino.

HC-SR04 Ultrasonic Sensor:

HC-SR04

Detects obstacles by emitting ultrasonic waves and measuring the time it takes for the waves to bounce back.

Servo Motor:

Rotates the ultrasonic sensor to scan the environment in multiple directions.

2-Wheel Kit:

Provides mobility. Each wheel is driven by a DC motor connected to the L293D motor driver.

9V Battery:

Provides power to the entire system.

 

Wiring Configuration

1. Arduino UNO to L293D Motor Driver Module:

IN1, IN2 (left motor): Connected to Arduino digital pins (e.g., D4, D5).

IN3, IN4 (right motor): Connected to Arduino digital pins (e.g., D6, D7).

Enable pins: Connected to 5V (for maximum motor speed).

Power connections:

VCC: External power source for the motors (e.g., battery).

GND: Common ground with Arduino.

2. HC-SR04 Ultrasonic Sensor:

VCC: Connected to Arduino 5V.

GND: Connected to Arduino GND.

Trig: Connected to an Arduino digital pin (e.g., D4).

Echo: Connected to an Arduino digital pin (e.g., D7).

3. Servo Motor:

Signal: Connected to an Arduino PWM pin (e.g., D10).

VCC: Connected to Arduino 5V.

GND: Connected to Arduino GND.

4. Power Supply:

The motors are powered by an external power source (e.g., 9V or 12V battery).

The Arduino can be powered by USB or an external battery.

 

Arduino program for the robot

You need to import AFMotor library to control the two motor and HCSR04 library to control the HC-SR04 sensors .

Testing and Tuning:

1. Place the robot in an environment with obstacles.

2. Test the robot's ability to detect and avoid obstacles.

3. Adjust the distanceThreshold and servo angles as needed for better performance.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info