Introduction
Obstacle avoider robots powered by Arduino and IR Sensor are the perfect introduction for thoseeager to learn robotics. Unlike other robotic systems, these sophisticated machines can navigatetheir environment autonomously using best-in-class infrared detection technology. As a result, theyhave an unprecedented ability to detect objects in front of them before making decisions aboutwhich direction is most suitable and safe from obstacles or any potential obstacles within range. Thisamazing feature makes it easier than ever before for users with little knowledge on how robots workand who want something fun vet easy to use-to set up obstacle avoidance navigation tasks quicklyand reliably without much fuss! With such powerful sensor technology integrated into theseincredible devices, your possibilities with autonomous robotics become endless!
In this blog, we will learn to build an obstacle avoiding robot based on Infra-Red sensors. Theprimary purpose of this bot is to traverse forward autonomously and change directions if itencounters any significant obstacle in its path, The bot will avoid any obstacle big enough to bedetected by the Infra-Red sensor mounted on the front.
Components required to make obstacle avoiding robot
1. Arduino Uno (with cable)
2. L298 Motor Driver
3. Range adjustable lR sensor(x3)
4. Chassis (x1)
5. B.0. DC Motors (x2)
6. Battery container (x1)
7. Wheels (x2)
8. Castor wheel
9. Jumper wires: male-to-malemale-to-femalefemale-to-female (x10)
10. switch (x1)
11. Spacers (x4)
12. M3*30 screw (x4)
13. M3*8 screw (x15
14. M3 nut (x15)
Step 1: Make the Robot itself
The first step is to make the bot itself, which comprises two driven wheels and a caster wheel at theback. The two front wheels are driven by 5V-12V B.0. Motors. The caster wheel is attached at the rearof the bot. This caster wheel helps the rear of the bot move freely as well as provides stability to theentire bot.
Step 2: Add the hardware required to power robot
The next step is to add the hardware required to power this bot and drive the wheels. We will beusing an L298 motor driver to drive the wheels and the entire system will be powered by a 3S(11.1V) LiPo battery. This dual bidirectional motor driver is based on the very popular L298 Dual H-Bridge Motor Driver lc. This module will allow you to control the two motors in both directions easilyand independently. We are also using a switch which will make turning on and off the bot easier.
Step 3:Add lR Sensor to detect obstacles
Now, moving on to the obstacle avoiding capabilities of the bot, we will be using a combination of 3IR sensors to detect any obstacles and the sensor data is processed by an Arduino Uno R3 to drive themotors accordingly, The code is fairly simple and can be broken down into 3 sections.
1. Declaration of all the variables and functions that we will be using in the program.
2. Setup function: In this, we declare pins 6, 9, 10 and 11 as output pins, these pins have PWMfunctionality which means we can control the speed of the bot, These pins are connected to theinput pins of the L298 motor driver. Additionally, two more GPl0 pins have been made high to
provide 5V to the lR sensors mounted on the front.
3. In the loop function, we keep reading the analog sensor value from the lR sensors, a flag israised if an obstacle is detected by the bot. The potentiometer can be used to tune to the sensorto detect an obstacle at a certain distance., Once an obstacle is detected by the lR sensors, a flag israised and the program enters a certain loop, in this loop, the bot decides to turn left or rightdepending on which side the obstacle has been detected. In case an obstacle has been detectedby the left lR sensor, the bot will move backwards briefly and them turn right. lf the obstacle hasbeen detected by the right lR sensor, the bot will briefly move backwards and then turn left. Thebot moves back briefly and turns away from the obstacle and starts moving forward again. Bydefault, the bot keeps moving forward until an obstacle is detected.