Hello friend!
In this tutorial, I'm going to show you how to make arduino 4in1 robot that you can easily build at home. First line follow robot, Second obstacle avoiding, Third the line follow robot with obstacle avoiding, and fourth the object follows robot.
Component Requirement:
1. Arduino Uno is the brain of the robot.
2. Motor driver l298n for controlling the motor.
3. 2 sets of IR sensors for line tracking and object follow.
4. Ultrasonic sensor (hc-sr04) with mount for detecting an object.
5. Servo motor.
6. 2 sets of Bo motors with the wheel.
7. Caster wheel.
8. Jumper wire.
now, we have all the components
Let's build the circuit:
First, Take a chassis 13 x 16 size and then stick Bo-motors on the bottom of chassis with the help of double tap after that stick a caster wheel too. With this robot easily move and rotate.
For command the robot we need an arduino uno and then we need a motor controller l298n and stick both on the chassis . you can also control motor with l293d IC.
Now connect the motor to the motor driver. Motor 1 is connected to the out 1 and 2. Motor 2 is connected to the out 3 and 4.
Connect the motor driver to the Arduino Uno.
First, EnableA pin is Connected to the Arduino pin 11.
IN1 pin is Connected to Arduino pin 13.
IN2 pin is Connected to Arduino pin 12.
IN3 pin is Connected to Arduino pin 7.
IN4 pin is Connected to Arduino pin 6.
EnableB is Connected to Arduino pin 5.
EnableA and EnableB is use for controlling speed of the motor.
Next, take a wheel and attach it to the Bo motor.
Next, take an IR sensor and stick it on the front of the chassis after that stick a breadboard too for power connection.
Connect the Arduino 5v pin to the breadboard positive side and
gnd pin to the breadboard negative side.
Now, connect the IR sensors to the Arduino Uno.
Connect right IR sensor Out pin to Arduino pin 4.
Connect the Vcc pin to the 5v.
Connect the GND pin to the GND.
Connect left IR sensor Out pin to Arduino pin 3.
Connect the Vcc pin to the 5v.
connect the GND pin to the GND.
Next, connect a dc jack with the switch to the motor driver for powering.
Positive terminal is connected to the motor driver input pin and Negative terminal is connected to the Motor Driver GND pin and also connect Arduino GND pin to the Motor Driver GND pin for a logic connection after that take servo motor and stick it on the chassis.
Connect servo motor signal pin to Arduino pin 2, Vcc pin to 5v, and gnd pin to gnd.
Next, Take an ultrasonic sensor and attach it to the mount with the help of a screw after that Attach an ultrasonic sensor on the top of the servo motor and secure it with a screw. It will help us to rotate the sensor and get the left and right distances. If you want to Know how ultrasonic sensor works?
To connect the ultrasonic sensor with Arduino.
Connect VCC pin to Arduino 5v pin.
Trig pin is Connected to Arduino A5 pin.
Echo pin is Connected to Arduino A4 pin.
Gnd pin is Connected to Arduino gnd pin.
Now stick a supporter on the mount with help of a double-tap and then take an IR sensor and stick it on the supporters. With this IR sensor robot can detect the object and follow it.
for the connection of IR sensor,
Left IR sensor signal pin is connected to Arduino pin A0.
Right IR sensor signal pin is connected to Arduino pin A1.
Connect VCC pin to 5v.
Connect gnd pin to gnd.
Now, take a 7.4-volt lion battery and stick it on the bottom of the chassis.
Don't use a 9v volt battery for powering the motor driver.
Connect the battery to the dc jack.
Now, the circuit is completed.
Coding:
connect the USB from computer to the Arduino for program it.
Upload the line follower code after that remove the USB and connect a 9v battery to the Arduino dc jack.
*** IMPORTANT***
Now, we have to calibrate the IR sensor for that rotate its potentiometer until it detected a black and white surface. If you put the robot on the black surface, an IR sensors second LED should be off and on the white surface LED should be on.
Now, Put the robot on the track and turn on the power connection.
The robot should be moving forward. If the robot is rotating or moving backward so switch the connection of that motor.
Put the robot on the track again.
Finally!, it's moving forward and also detecting the track.
Explanation of Line follower robot :
When both IR sensors are on the white surface, so the robot moves forward otherwise inverts the connection of that motor.
If the left sensor appears on a black line, the robot move right.
If the right sensor appears on a black line, the robot move left.
If both sensors come on the black line, the robot stops.
Explanation of Arduino obstacle avoidance.
When the ultrasonic sensor detects an object within a given range then the robot stops and looks right to check for an obstacle, if there is no obstacle is detected, turn the robot to the right and move forward in that direction.
If there is an obstacle on the right side, look left, if there is no obstacle is detected, turns the robot to the left and move forward in that direction.
If an obstacle detects in all three directions, rotate the robot to 180 degrees and go forward.
Explanation of line follows with obstacle avoidance.
Robot keep tracking the line and until an ultrasonic sensor detects an object in a given range, then the robot stops, looks left, right, and gets the distances. If the object is on the right and front side, the robot moves on the left side, and if the object is on the left and front side, the robot moves on the right side.
Object follow robot.
In this mode, the robot tracking the object. This is very cool and fun projects.
The ultrasonic sensor is use to detects the distance of the object(near or far) and IR sensor is use to detects where the object is move(left or right).
We need to calibrate the IR sensor for object detection. Put an object in front of the First IR sensor and the distance between object and IR sensor is 5 cm after that rotate is potentiometer until the second led is turn off. Do the same process for another IR Sensor.
When there is no object detects by the ultrasonic sensor and IR sensor the robot should be stop and if the object is detected within 30 cm range it move forward and keep tracking it. If the right IR sensor detect the object, the robot move right and If the right IR sensor detect the object, the robot move left.
This is how its work. if you getting any problem comment it or contact me on Instagram. will help you as soon as possible.
Code arduino 4IN1 robot
If you like this video so subscribe to my channel and comment down on what next video you want to see?