Very Simple Robot for Beginners
by Nikus in Circuits > Arduino
55250 Views, 674 Favorites, 0 Comments
Very Simple Robot for Beginners
![DSC04164.jpg](/proxy/?url=https://content.instructables.com/FZQ/HFTN/IEX52NK0/FZQHFTNIEX52NK0.jpg&filename=DSC04164.jpg)
![Very simple robot for beginners](/proxy/?url=https://content.instructables.com/FHY/AABT/IF3SSHVU/FHYAABTIF3SSHVU.jpg&filename=Very simple robot for beginners)
This instructable shows you how to make very simple robot. It will detect obstacles and avoiding it. This is great project for someone who is new to arduino and want to make first robot.
Why robot?
Because it's great way to learn arduino programming and how e.g. motor driver works. In addition It's nice feeling when you build your first robot and its detects and avoids objects.
Why this kit is good for start?
When I started with arduino I don't know what e.g. H bridge means, which sensors or motors to buy. This kit is very practical, because you don't need to buy anything else to build your own robot. Only you need is screwdriver, zip-ties, nippers and arduino IDE.
Parts
![parts.jpg](/proxy/?url=https://content.instructables.com/FT0/BGB1/IEX4M6G1/FT0BGB1IEX4M6G1.jpg&filename=parts.jpg)
![DSC04153.JPG](/proxy/?url=https://content.instructables.com/FGX/AJY2/IEX52NLV/FGXAJY2IEX52NLV.jpg&filename=DSC04153.JPG)
You can either buy a full kit with all the parts that I will use in this project or you can buy everything separately.
Because it is only 25$, it's pretty cheap and in this kit you have all things that you need to start with arduino. Instead of 6 x 1.5V batteries I use my 6V accumulator because I haven't 6 batteries. Additionally you need 2 zip-ties to fasten ultrasonic sensor.
What you can find in the kit?
- Arduino
- Motors driver
- Motors
- Ultrasonic sensor
- Servo
- Plastic plates to build a chassis
- Pieces of plastic to fasten a servo
- Wheels (two big and one small)
- Cables
- 6 x 1.5V and 9V battery holder
- USB cable
- Some small screws and other stuff
Chassis Building
![Simple robot building](/proxy/?url=https://content.instructables.com/F1N/LPON/IEX5368D/F1NLPONIEX5368D.jpg&filename=Simple robot building)
![DSC04155.JPG](/proxy/?url=https://content.instructables.com/FTN/C0EF/IEX52NOV/FTNC0EFIEX52NOV.jpg&filename=DSC04155.JPG)
![DSC04157.JPG](/proxy/?url=https://content.instructables.com/FNY/IKVQ/IEX52NPK/FNYIKVQIEX52NPK.jpg&filename=DSC04157.JPG)
This chassis is very easy to build, it came with fitted motors, rear wheel and motor driver. On the video you can see what is inside the pack and how to build it. If this video is too fast for you, you can slow it down in video options on YouTube.
Connection
![connection_bb.jpg](/proxy/?url=https://content.instructables.com/FZ2/4NHY/IEX4QR4T/FZ24NHYIEX4QR4T.jpg&filename=connection_bb.jpg)
![DSC04152.JPG](/proxy/?url=https://content.instructables.com/FDW/BSEP/IEX52NKX/FDWBSEPIEX52NKX.jpg&filename=DSC04152.JPG)
![DSC04150.JPG](/proxy/?url=https://content.instructables.com/F4Q/PQBM/IEX52NKN/F4QPQBMIEX52NKN.jpg&filename=DSC04150.JPG)
![DSC04154.JPG](/proxy/?url=https://content.instructables.com/FE9/GZ41/IEX52NN7/FE9GZ41IEX52NN7.jpg&filename=DSC04154.JPG)
Sorry, that I added notes with names of pins but I can't find this parts on the internet. I connect all things without breadboard. If you have any questions leave a comment. I have not used breadboard to simplify connection and so looks less complicated.
Program
In comments I explained what each line makes. This is very simple code I have hope that you understand it.
/*
* Code wrtitten by Nikodem Bartnk * visit: * https://www.instructables.com/member/Nikus/ * http://arduinopolska.cba.pl/ * https://spongepie.com/ * * C by Nikodem Bartnik * If you have question you can write here: * nikodem.bartnik@gmail.com *///speed of motors betwen 0 and 255, if you like you can change it int pwm_speed = 255; //trig of ultrasonic sensor int trig = 12; //echo of ultrasonic sensor int echo = 13;
void setup() {
//pins for motor controller pinMode(11, OUTPUT); pinMode(10, OUTPUT); pinMode(9, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); pinMode(3, OUTPUT); //set trig as output and echo as input for ultrasonic sensor pinMode(trig, OUTPUT); pinMode(echo,INPUT);
}
void loop() {
digitalWrite(trig, LOW); delayMicroseconds(2); digitalWrite(trig, HIGH); delayMicroseconds(5); digitalWrite(trig, LOW);
int duration = pulseIn(echo, HIGH); int distance = duration / 29 / 2;
if(distance > 10){ //move forward by 100 ms forward(100); }else if(distance < 10){ //backward by 1000ms = 1 second backward(1000); //left by 1000ms = 1 second left(1000); } }
// function for driving straight void forward(int delay_time){ digitalWrite(11, HIGH); digitalWrite(10, LOW); digitalWrite(9, HIGH); digitalWrite(6, LOW);
analogWrite(5, pwm_speed); analogWrite(3, pwm_speed); delay(delay_time); }
//function for reversing void backward(int delay_time){ digitalWrite(11, LOW); digitalWrite(10, HIGH); digitalWrite(9, LOW); digitalWrite(6, HIGH);
analogWrite(5, pwm_speed); analogWrite(3, pwm_speed); delay(delay_time); }
//function for turning left void left(int delay_time){ digitalWrite(11, HIGH); digitalWrite(10, LOW); digitalWrite(9, LOW); digitalWrite(6, LOW);
analogWrite(5, pwm_speed); analogWrite(3, 0); delay(delay_time); }
//function for turning right void right(int delay_time){ digitalWrite(11, LOW); digitalWrite(10, LOW); digitalWrite(9, HIGH); digitalWrite(6, LOW);
analogWrite(5, 0); analogWrite(3, pwm_speed); delay(delay_time); }
//function for stopping motors void motors_stop(int delay_time){ digitalWrite(11, LOW); digitalWrite(10, LOW); digitalWrite(9,LOW); digitalWrite(6, LOW);
analogWrite(5, 0); analogWrite(3, 0); delay(delay_time); }
Conclusion
![DSC04161.JPG](/proxy/?url=https://content.instructables.com/F3X/SY5R/IEX5355R/F3XSY5RIEX5355R.jpg&filename=DSC04161.JPG)
I think that this robot is great for someone who just started with arduino and like to build first robot. Of course if you like you can add some parts and make it more advanced e.g. add bluetooth, android phone and make object tracking robot. Don't forget to leave a comment :)
Have fun with your robot!