**Updates: wiring diagram,
step by step tutorial
Tutorial:
This is a simple autonomous robot which you can make easily at home without much experience of electronics and coding. It works on the principle of echolocation using the SONAR. The ultrasound sensor is used for detecting the obstacle. It basically moves around and if it detects any obstacles in its path it will avoid and find its way out.
List of components with Estimated price in INR:
1. Arduino: Any arduino will do- Arduino UNO, Nano, Mega, Mini, Micro etc.
(Estimated Rs. 500)
2. Ping Sensor/ ultrasound sensor: HC SR-04
(estimated Rs. 150)
3. Servo motor: Micro Servo motor SG90/ MG90
(estimated price Rs.300)
4. BO motor 60-150 RPM two pieces
(estimated price Rs. 300)
**please select motor RPM of not more then 150 RPM because it becomes unstable.
6. BO motor wheel two pieces
(estimated price Rs.150)
7. Motor Driver: L298 motor driver
(estimated Price Rs.250)
8. Castor Wheel
(Estimated Price Rs.100)
9. Jumper Wire:
(Estimated Price Rs. 100)
10. Battery: 12V
(you can buy a rechargeable or you can run from AA/AAA batteries by connecting them in series to obtain 12 volts. But I suggest you buy a rechargeable one because its a pain in the ass to buy a new dry cell every time.)
(estimated cost: depends upon what you choose: Rs. 80- 1000
10. Chasis: You can buy a ready made or you can make one of your own like I did.
( in case you buy Estimated: Rs. 150)
Now once you have all the above materials you are ready to go.
Watch the tutorial Video and SUBSCRIBE to my channel or continue reading.
Steps:
1. First of all plan how you want the robot to look. It may be very simple or nice looking like Wall-E.
2. Solder all the terminals of the motors and sensors. you can connect them with jumper wire too.
3. once the soldering is done, place all the components in their places. I don't have any idea how you want to and where you wish to place them but I suppose you have plan it well.
4. Next connect all the wires All GND to Common. And other wires to their designated place.
5. Upload the codes and make a test run.
** if the motor seems to spin in opposite directions, just reverse the wire of the motor.
**if the turning of the robot is not very efficient adjust the delay of the motor on time on the code.
**in case you motor is of high RPM and you want the robot to move a bit slower, adjust the PWM output.
the wiring diagram is given below.
IF YOU NEED ANY HELP COMMENT IN THE YOUTUBE COMMENT SECTION.
Wiring Diagram
____________________________
New Ping Library, Download from here →
https://playground.arduino.cc/Code/NewPing
The codes for the robot:
Please copy the codes after the line and paste it directly.
_________________________________________________________________
_________________________________________________________________
//This is the code for the robot
// make sure to include the NewPing and Servo Libraries before uploading else it will show error
#include <NewPing.h>
#include <Servo.h>
#define TRIG_PIN A4
#define ECHO_PIN A5
#define MAX_DISTANCE 200
NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);
Servo myservo;
boolean goesForward=false;
int distance = 100;
int speedSet = 0;
const int motorPin1 = 11;
const int motorPin2 = 10;
//Motor B
const int motorPin3 = 6;
const int motorPin4 = 5;
void setup() {
myservo.attach(9);
myservo.write(115);
delay(2000);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
}
void loop() {
int distanceR = 0;
int distanceL = 0;
delay(40);
if(distance<=20)
{
moveStop();
delay(100);
moveBackward();
delay(600);
moveStop();
delay(200);
distanceR = lookRight();
delay(200);
distanceL = lookLeft();
delay(200);
if(distanceR>=distanceL)
{
turnRight();
moveStop();
}else
{
turnLeft();
moveStop();
}
}else
{
moveForward();
}
distance = readPing();
}
int lookRight()
{
myservo.write(50);
delay(500);
int distance = readPing();
delay(100);
myservo.write(115);
return distance;
}
int lookLeft()
{
myservo.write(170);
delay(500);
int distance = readPing();
delay(100);
myservo.write(115);
return distance;
delay(100);
}
int readPing() {
delay(70);
int cm = sonar.ping_cm();
if(cm==0)
{
cm = 250;
}
return cm;
}
void moveStop() {
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, 0);
}
void moveForward() {
analogWrite(motorPin1, 230);
//the value 230 here is a PWM so you can change it depending up on your motor speed
//the value 230 here is a PWM so you can change it depending up on your motor speed
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 230);
// this one too is the PWM for other motor
// this one too is the PWM for other motor
analogWrite(motorPin4, 0);
}
void moveBackward() {
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 230);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, 230);
}
void turnRight() {
analogWrite(motorPin1, 240);
analogWrite(motorPin2, 0);
analogWrite(motorPin3, 0);
analogWrite(motorPin4, 230);
delay(1200);
moveForward();
}
void turnLeft() {
analogWrite(motorPin1, 0);
analogWrite(motorPin2, 240);
analogWrite(motorPin3, 240);
analogWrite(motorPin4, 0);
delay(800);
moveForward();
}
_______________________________________________________________________
_______________________________________________________________________
How To Make a Simple Autonomous Robot
Reviewed by Unknown
on
February 25, 2017
Rating:
Very Nice
ReplyDeletenewping error, why ?
ReplyDeleteThis comment has been removed by the author.
Deleteyou miss the NEWPING sensor librairy, include it or install it from github
DeleteThank you for your help Bro. :)
DeleteVery good, Can this work with arduino uno and adafruit motorshield v2 ?
ReplyDeletecould you post a code for this if possible...Thanks
How to include the new ping abd servo libraries
ReplyDeleteinstal servo librairy, or if you have it, put it in the code by choose it
DeleteBrilliant !!! thank you!
ReplyDeletecan we use arduino UNO instead of nano?
ReplyDeleteYES
DeleteWorks on 1 power on! Great!
ReplyDeleteIt seems that GRD for the Nano is missed . And is it correct that servo gets grd from 12V and vcc from 5V? I am confused.
ReplyDeleteThanks for telling that. i missed to connect the GND of the arduino.
Deleteand yeah, GND works for all as common, battery, ping, arduino, servo.
1 GND is enough H-bridge will take care of it.
ReplyDeleteGreat work.
New ping lib you can add from arduino program go to library and add NewPing.
Excellent. It worked immediately, but my model shortly after running starts spinning on itself and enters in a loop that can not leave until I put my hand or a piece of paper in front of the ultrasonic sensor.
ReplyDeleteCould you tell me what the problem is? Thank you very much for your valuable design.
Mario.
If u made this project could u tell me about this connections??
DeleteHi, I found most parts in my usual shops. But I'm uncertain about the battery 12v.
ReplyDeleteAnyone who can give some more info what kind of battery is needed?
I uploaded the codes and connected the 9 v battery not working and how did you make the 12 v battery I just don't know the connections to make 12 v battery
ReplyDeleteI believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleterpa Training in Bangalore
hi! i’m making these project for school and i chave a big roblem because nothing work 😭😭😭 can i put on arduino „hot metal” ( i dont now the world) besause it start to burn 😟😟😟 i have 2 days pleas help!
ReplyDeletehi! i’m making these project for school and i chave a big roblem because nothing work 😭😭😭 can i put on arduino „hot metal” ( i dont now the world) besause it start to burn 😟😟😟 i have 2 days pleas help!
ReplyDeletehola ...a la hora de compilar muestra stray ´303´ in program y voy a esa linea del programa y es en más:
ReplyDeletemoveStop ();
}
}más /....303 aqui muestra error
Sir great work u have done making this bot . Please continue to make Arduino nano based similar robots.
ReplyDeleteCan you send me the connection of this project??
ReplyDeleteWhat are the dimensions of the chasis?
ReplyDeleteperde modelleri
ReplyDeletesms onay
Turkcell Mobil Ödeme Bozdurma
Https://nftnasilalinir.com
ankara evden eve nakliyat
TRAFİK SİGORTASİ
dedektör
web sitesi kurma
ASK ROMANLARİ
tuzla alarko carrier klima servisi
ReplyDeleteüsküdar lg klima servisi
üsküdar daikin klima servisi
pendik toshiba klima servisi
tuzla daikin klima servisi
çekmeköy toshiba klima servisi
ataşehir toshiba klima servisi
çekmeköy beko klima servisi
ataşehir beko klima servisi
Good content. You write beautiful things.
ReplyDeletesportsbet
vbet
hacklink
vbet
mrbahis
korsan taksi
hacklink
mrbahis
sportsbet
Good text Write good content success. Thank you
ReplyDeletebonus veren siteler
kralbet
betmatik
slot siteleri
tipobet
betpark
poker siteleri
mobil ödeme bahis
niğde
ReplyDeletekırklareli
osmaniye
siirt
urfa
0W2H
bitlis
ReplyDeleteedirne
hatay
ağrı
urfa
R06QY2
salt likit
ReplyDeletesalt likit
dr mood likit
big boss likit
dl likit
dark likit
C7CNQ
https://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
KO84
شركة تنظيف بالجبيل
ReplyDeleteشركة تنظيف