Introduction: How to Make Arduino Human Following Robot.
Hey Guys, welcome to my first instructables article. So guys today we are going to make a " Human following Robot using Arduino nano" seems to be interesting Right?
Let me first tell you about the main working principle of this robot:
This human following will be having a ultrasonic sensor which will work as a medium of tracking the object that comes in front of it. We will be coding the arduino nano in this way that when a object comes near ultrasonic sensor and if its distance is less than 5cm then it will go backward and if it is more than 10 cm and less than 20 cm, than it will go forward and more than 20 cm and less than 25 cm, than it will go left etc...
if you have not understood its working principle then take a look at the whole tutorial you might then understand it...
Special thanks to JLCPCB for providing me with their quality PCBs.
Key features:
~ Items/gears used in the project are easily available.
~ Low cost project.
~ Not much complicated circuit.
~ Best example for learning AI.
So let's get started with the project :-)
Step 1: Items That You Require for Making the Project:
- Arduino nano: https://amzn.to/30EDliS
- L298N Motor Driver: https://amzn.to/34vTY1w
- UltraSonic Sensor: https://amzn.to/34pdT2E
- Servo motor: https://amzn.to/3rcDDJl
- Gear motor: https://amzn.to/3rSL9cy
- Rubber wheel: https://amzn.to/3eFXwVp
- Header pins: https://amzn.to/3iAzx8t
- Battery holder: https://amzn.to/3qRxHEz
- Battery: (Get it in old power banks)
- Custom PCB: JLCPCB
Step 2: Making of the Chassy :
~ So for making the chassy I am using a cardboard which is cut 10*14 cm.
~ Then we need a gear motor 4pcs.
~ We will stick the motor with the cardboard using hot glue gun.
~ We move into the wiring of the motors, the wiring will go in this way we will solder the wires of the same side in crossward direction. As shown in the above image.
~ We will require a rubber wheel (4pcs) for the motor.
~ Then our chassy will be ready.
lets move into the next step...
Step 3: Attaching the Motor Driver With the Chassy:
~ over here we will be using the L298N Motor driver.
~ Attach the motor driver the back side of the chassy with the help of glue. As shown in the image.
~ Then you need to connect the motors wire to the motor terminals of the motor driver.
and that's all you need to do for making chassy functional.
Step 4: Making of the Circuit and Then Converting It Into PCB.
In this project, i am using custom designed circuit board to give more profesional touch. So i chose JLCPCB to design and order the custom designed PCB for this project.
Circuit Schematic: URL
Gerber File: URL
About JLCPCB
JLCPCB (Shenzhen JIALICHUANG Electronic Technology Development Co., Ltd.), is the largest PCB prototype enterprise in China and a high-tech manufacturer specializing in quick PCB prototype and small-batch PCB production. With over 14 years of experience in PCB manufacturing, JLCPCB has more than 200,000 customers at home and abroad, with over 8,000 online orders of PCB prototyping and small quantity PCB production per day. The annual production capacity is 200,000 sq.m. for various of 1-layer, 2-layer or multi-layer PCBs, now also provides SMT and STENCILS Service at very low cost. JLC is a professional PCB manufacturer featured of large scale, well equipment, strict management and superior quality.
Special offer from our side :-)
$2 for 1-4 Layer PCBs, sign up to get $18 new user coupons: JLCPCB Discount Coupon Code:- JLCPCBcom
How I made the Gerber file:
EASYEDA is a free and easy to use circuit design, circuit simulator and pcb design that runs in your web browser.
Step 5: Mount the Arduino and Motor Drivers
After 7 days I got the 10 High Quality PCB from JLCPCB . Then I mounted all the header pins into it and soldered them.
~ Now it's time to mount the Arduino nano with the PCB and making all the necessary connections between the components and PCB.
~ Here first we will make connection between the motor driver and the Arduino.
Motor driver pins with Arduino pins:
IN1 to D5
IN2 to D4
IN3 to D3
IN4 to D2
enA to D6
enB to D7
~ So that all we need to do with the motor driver pins...
Step 6: Mounting of Sensors, Servo Etc...
In this part we will be require the UltraSonic sensor, Its Mount, Servo motor...
~ First we will stick the Servo with the chassy.
~ Then we will take the UltraSonic sensor and its mount.
~ Then we will put the UltraSonic sensor in the mount.
~ After that we will place the mount in the servo.AS SHOWN IN THE IMAGE...
Step 7: Connection of Servo, UltraSonic Sensor...
So we will make the connection of servo, UltraSonic sensor with the arduino.
~ Connect the servo to the servo pins Available in the PCB.
~ Simply connect the UltraSonic sensor pins as shown here:
trig to D10
echo to D11
GND to Gnd
VCC to +5V
And that's all connections are done. Very easy and simple.
Step 8: Time to Upload the Sketch.
~ Before Upload the Sketch don't forget to remove the servo wire and UltraSonic sensor's wire from the PCB.
~ Then connect the Arduino nano's wire in your pc.
~ Then open the Arduino IDE and upload the code to it.
/*Human folling robot using Arduino nano. * code created by: DIY Burner *NOTE : Please don't forget to include the library "Servo.h". *For any query contact me on Instagram. (id: diy.burner) *code version: 1.0.0 */ #include <Servo.h> const int trigPin = 10 ; //Servo trig pin to D10 const int echoPin = 11; // Servo echo pin to D11 const int in1 = 5; // Motor driver pin const int in2 = 4; const int in3 = 3; const int in4 = 2; const int enA = 6; const int enB = 7; #define motorArpm 170 // Default speed for "enA". you can change this speed from 0 to 300 #define motorBrpm 170 // Default speed for "enB". you can change this speed from 0 to 300 Servo servo_motor; //Servo int pos =0; void setup(){ Serial.begin(9600); servo_motor.attach(8); //Servo signal pin to D8 { for(pos = 90; pos <= 180; pos += 1){ servo_motor.write(pos); delay(15); } for(pos = 180; pos >= 0; pos-= 1) { servo_motor.write(pos); delay(15); }for(pos = 0; pos<=90; pos += 1) { servo_motor.write(pos); delay(15); } pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode (in1, OUTPUT); pinMode (in2, OUTPUT); pinMode (in3, OUTPUT); pinMode (in4, OUTPUT); pinMode (enA, OUTPUT); pinMode (enB, OUTPUT); } } long duration; int distance; void loop(){ digitalWrite(trigPin , HIGH); delayMicroseconds(1000); digitalWrite(trigPin , LOW); duration = pulseIn(echoPin , HIGH); distance = (duration/2) / 28.5; if(distance < 5) // It will go Backward if distance is less than 5. { digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enA, motorArpm); digitalWrite(in3, LOW); digitalWrite(in4, HIGH); analogWrite(enB, motorBrpm); } if(distance >40) // It will Stop if distance is More than 40. { digitalWrite(in1, LOW); digitalWrite(in2, LOW); digitalWrite(in3, LOW); digitalWrite(in4, LOW); analogWrite(enA, 0); analogWrite(enB, 0); } if(distance > 10 && distance < 20){ // to turn Forward digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(enA, motorArpm); digitalWrite(in3, HIGH); digitalWrite(in4, LOW); analogWrite(enB, motorBrpm); } if(distance > 20 && distance < 30)//// to turn left { digitalWrite(in1, LOW); digitalWrite(in2, HIGH); analogWrite(enA, 150); digitalWrite(in3, LOW); digitalWrite(in4, HIGH); analogWrite(enB, 160); } if(distance > 30 && distance <40 ) //// to turn Right { digitalWrite(in1, HIGH); digitalWrite(in2, LOW); analogWrite(enA, motorArpm); }
~ OR Download the code from Google DRIVE: Download Code
Step 9: All Set, Now It's Time to Test It.
Don't forget to attach the battery holder and connect the wire of the holder to the motor driver and arduino nano.
Watch our YouTube video to see the its testing video. Watch Now!
Step 10: We're Done Now
We're Done Now. I hope you like my project and if you have any query then leave your comments here I will surely help you with it or if you have any idea of any new type of project then please comment here I will be definetly make it.
I'll keep updating this instructable.
Thanks for watching project, I hope you liked this project, if you did then please follow me I'll keep posting awesome new projects. Also, don't forget to SUBSCRIBE my YouTube channel. (YouTube: DIY BURNER)
Thank you...Bye...Bye