Make your first arduino robot - The best beginners guide!

Monday, July 11, 2016


Smartphone controlled , obstacle avoiding and wall follower robot.
Are you a beginner in arduino and have a plan to make your first robot then follow this tutorial.
Are you not yet used an arduino then-have a familiar of this by feeling it.
What about making your own robots. It's really cool thing?.But don't know where to start. Then this tutorial is (best) for you. In this tutorial I am going to show how to make an arduino robot with different functionalities in cheap price. We can learn the use of different programs for different functions, mainly a smart phone controlled robot with Obstacle avoid er, wall follower or maze solver robot etc or You can also make it for a single function.


Watch this video to see it's final working.


Watch this video to see it's autonomous function.


Visit last step to learn editing the Bluetooth app - 'Bluetooth Electronics'


Here download all the files - Arduino codes and circuit diagram.

Materials and tools.

Meterials-

If you are using l293D or l298N IC or modules instead of adafruit motor shield CLICK HERE or visit the last section of this tutorial.

My reccomendation in battery selection
 It is better to use a power bank to power the arduino and use some type of rechargeable lithium-ion or lead acid battery for power the motor shield, the 9 volt battery may exhaust soon but it is very cheap.

Why choosing the l293d Adafruit Motor Shield ?
It's low cost device, easy to use and easily available motor shield which does not require any previous skills. It can be also programmed easily by using adafruit 'afmotor' library.

Tools-
  • Screw driver
  • Soldering iron
  • Hot glue gun
  • Driller

Step 1: Making the chasis.




Drill two holes for motor

Connect two motors

Make three holes for caster wheel

Connect the caster wheel


Make two holes on either side of the box for connecting the motors and three holes on the down side for connecting the caster wheel after measuring and marking the correct diameter. Then connect the motor after soldering the wire to motor shield and connect the caster wheel.

Step 2: Connecting battery


Connecting the batteries.


Connection diagram.

Place two battery and glue it inside the box.

Take out wire from the battery.

Take two 9 volt battery and place it inside the box above the caster wheel. Then wire this battery in parallel mode and connect a switch as shown in above diagram . This is the batteries that giving power to motor shield.

Step 3: Connecting the arduino and motor shield


Attach the motor shield above the arduino.

Connect the the wires from battery to pwr of motor shield.


Connect the wires from motors to motor shield.
Remove the jumper from this port.

Connection diagram.
Connect the motor shield above the arduino and place it above the battery. Then connect the wires from the motors and battery to the motor shield. Look out the connection diagram before connecting, as it is very important .
Wiring Instructions -
- Connect the left motor to "M1" of motor shield
- Connect the right motor to "M3" of motor shield
- Connect the the wire from battery to "ext pwr " of motor shield
Don't forget to remove the jumper from the "pwr" of motor shield

Step 4: Make two holes and power the arduino.


Mark the spot to make holes. 

Make the holes.

Connect the battery clip to dc male jack to the 9v battery.


Place this 9 volt battery inside the box.

Connection diagram
Make two holes for accessing the USB port and DC input port of arduino. Take another 9 volt battery and connect battery clip to dc male jack adaptor ,then connect the DC male jack to arduino DC input port, to power the arduino. Then place the battery between the motors and arduino inside the box.
(It is better to use a power bank to power the arduino the 9 volt battery may exhaust soon)

Step 5: Connecting bluetooth module and switch.



Connect the Bluetooth module with Arduino.

Place the bluetooth module inside the box.


Take the switch from first battery connection and make a hole for connecting it.


Connect the switch.


Connection diagram.

Connect the Bluetooth module to arduino as shown in the connection diagram and place it inside the box. Then make hole to connect the switch on the back side of the box and connect the switch (here I have changed the switch which is used earlier because of some soldering problem).
Wiring Instruction of bluetooth module -
- "TX of Bluetooth Module" goes to "RX of Arduino"
- "RX of Bluetooth Module" goes to "TXof Arduino"
- "VCC of Bluetooth Module" goes to "5v of Arduino"
- "GND of Bluetooth Module" goes to "GND of Arduino"
- The State & Key pins of the BT modules are kept unused.

Step 6: Circuit diagram. Connecting ultrasonic sensor and finishing.


Updated circuit diagram

The complete connection diagram/ Circuit diagram. "Download and zoom in for clear view."
(old)The complete connection diagram/ Circuit diagram.
Lest take a L shaped plastic piece.


Glue it over the ultrasonic sensor.


Make a hole on the cap of the box.


Connect the wire from ultrasonic sensor and glue it on the box.


Connect the wires to arduino.


Now you are finished.

Take the ultrasonic sensor and glue a small 'L' shaped plastic piece to it and glue it over the plastic box(or if not having a glue stick use double sided tape ). Then connect the jumper wires to as shown in the circuit diagram above.
Wiring Instruction of ultrasonic sensor -
- "VCC of Ultra sonic sensor" goes to "5 volt of Arduino"
- "GND of Ultra sonic sensor" goes to "GND of Arduino"
- "Trig pin of Ultra sonic sensor" goes to "Dgital pin 9 volt of Arduino"
- "Echo pin of Ultra sonic sensor" goes to "Digital pin 8 of Arduino"
Now we finished the all the connections and it's the time to program.

Step 7: Last step - Arduino codes and bluetooth app editing

First download the ARDUINO IDE from arduino.cc(here) and install on your PC. Download the above files and Upload it. thus we learned how to program a Arduino easily. I have shown here some programs to work this robot as a obstacle avoiding robot, Wall follower, and Bluetooth controlled. and at last I have combined this three functions together using a bluetooth app. Watch the videos for more details and information.

You can use the wall follower robot code to function it as a maze solver robot.

Install the 'AFmotor' library before compiling the program. Copy paste the AFmotor folder to to arduino libraries folder.Download from here.


Autonomous robot - Obstacle avoiding robot and Wall follower robot code - Video




The Final code- Video




Editing Bluetooth electronics app for the robot - Video






Programs for the robot

Readers who made there first robot by following this tutorial.

Ujjwal Agrawal from Kanpur, U.P
contact: 9554523226
Sai Gowtham from Vijayawada, Maharashtra
contact: not provided.

Ashish Philip Thomas
contact: 9562555078
To inspire others, you can also add your robot's image that you made by following this tutorial. Sent your robot's image to image@robotechmaker.com.

Still have problems? Doubts? Comment below.
Here we can help each other.

You Might Also Like

64 comments

  1. +Muhammad Azhar Aslam u Alikum bro i have some queries about obstacle avoiding robo but i add a servo attach ultrasonic sensor on top of servo for scan left and right .
    bro but unfortunately they donot work properly i try 3 month to make it but every time i face some problem recently i made another robo same like your robo but they move very slow whwn i unplugged the usb cable form pc i used rechargeable ni-mh 9.6v battery but every time i face some problem can u plz help me about the robo your sincere Hamza

    ReplyDelete
    Replies
    1. Use12 volt lead acid battery or six AA battery in series connection mode to power the motor controller instead of two 9 volt battery it may solve your problem. If not then please say the exact problem here.

      Delete
  2. Muhammed Azhar can you let me know how to this project with L293MD

    ReplyDelete
    Replies
    1. Yes sure. Here I made the updates. Visit the last section of this tutorial.

      Delete
  3. Bro can i use normal 6v dc motors?? or its will fail? m beginner:D

    ReplyDelete
    Replies
    1. Is it geared or not? Robot will will work fine with 6 volt geared motors and can use the same connection as above.
      Are you using this type of motor? copy paste this link in a new tab(https://www.amazon.com/ZJchao-Arduino-Plastic-Wheel-Motor/dp/B01934CLG4/ref=sr_1_7?ie=UTF8&qid=1474134074&sr=8-7&keywords=6+volt+motor)

      Delete
  4. hey help me, im making line follower with obstacle avoiding . can you help me with programme and the diagram. plz send the details to eh.akshay8@gmail.com or replay in here

    ReplyDelete
  5. I am already making a new tutorial for line follower robot with the same platform of this tutorial. Wait for a few weeks. Visit here to see my upcoming projects -
    http://www.robotechmaker.com/p/all-projects.html
    Stay connected!

    ReplyDelete
  6. in your code the pins of the sensor are 14 n 15 but there is no pin on arduino

    ReplyDelete
    Replies
    1. In the program we can also represent the analog pins of arduino 'A0' and 'A1' as '14' and '15'. To check the connection please refer the circuit diagram above.

      Delete
    2. ma robot running wrong ways and slow

      Delete
    3. Are you connected everything in right way? Check once more. OR ask the exact problem here. And also take a look in my recommendations in using battery etc.

      Delete
  7. HI I AM GAGAN.
    CAN YOU ADD AN EXACT LINK OF WHICH AF MOTOR LIBRARY THAT I HAVE TO DOWNLOAD.I AM GETTING CONFUSED WHICH ONE TO DOWNLOAD IN THE LINK THAT YOU HAVE POSTED ABOVE THERE ARE SO MANY THINGS IN THE LINK.PLEASE HELP ME.

    ReplyDelete
    Replies
    1. Go to the link > click clone or download > download zip > after downloading the zip extract the zip > rename the folder as 'AFmotor' > then Copy paste the folder to "C:\Users\home\Documents\Arduino\libraries" (in windows).

      Delete
  8. WHEN I CLICK ON UPLOAD IN THE ARDUINO SOFTWARE IT GIVES A MESSAGE SAYING 'ERROR COMPILING FOR ARDUINO BOARD'.

    ReplyDelete
  9. SORRY,BUT THE ARDUINO SOFTWARE(1.6.11)STILL GIVES ME ERROR WHILE UPLOADING.IT SAYS 'ERROR COMPILING FOR ARDUINO BOARD'. THEN THE FOLLOWING TEXT COMES-
    Arduino: 1.6.11 (Windows 8), Board: "Arduino/Genuino Uno"

    E:\gagan\ardino_code1\ardino_code1.ino:196:21: fatal error: AFMotor.h: No such file or directory

    #include "AFMotor.h"

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    PLEASE HELP ME.THIS IS MY FIRST ARDUINO PROJECT AND I AM IN GRADE 8.
    THANK YOU

    ReplyDelete
    Replies
    1. Try it by using latest arduino IDE. For more trouble shooting join our slack group.Go here - https://diy-makers.herokuapp.com/ .

      Delete
  10. kardeşim ben türkiyeden yazıyorum.harika işler yapmışşsın başarılarının devamını diliyorm. senin projenden bende yararlanıyorum değişiklikler yaparak türkiyedeki proje merkezine (TÜBİTAK) sunuyorum. ÇOK TEŞEKKÜRLER

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. I am updated the code and the final circuit diagram please follow that diagram to connect your ultra sonic sensor.

      Delete
  12. HEY CAN U PLS SEND THE CIRCUIT DIAGRAM USING L298N AT manassukriti@gmail.com

    ReplyDelete
    Replies
    1. You can find it here. In the last section of this post.

      Delete
  13. Hai,,, when i compile sketch i foud error,,undeclared identifier 'MOTOR12_64KHZ' and undeclared identifier 'CHECK' please help

    ReplyDelete
    Replies
    1. Which code from the above give this error? Are you installed the AFmotor library and tested the motor shield?

      Delete
    2. The library AFMotor installed,,
      Motor shield not test,,, oke i try this,,,, and i try compile use arduino uno board massage collect2.exe:error:id returned 5 exit status,, and if i compile use genuino Mega Or Mega 2560 board is sucsesed,, but i dont have arduino mega i have arduino uno,, oke fried,, thank you,,,

      Delete
    3. This comment has been removed by the author.

      Delete
    4. I am also used the Arduino UNO with the same code. Please use the latest version of Arduino IDE it may solve your problems.

      Delete
  14. muhamed first off all thanks for your tutorial,i am done with my project because i am follow your instruction, everything work fine,but since 2 week ago i try to compare my project using another code to control led using your program,i mean i want to make my robot can control on/off the led and turn on/off buzzer as well,but until now always fail ,can you help me please,to make the code/program my email is madewira27@gmail.com thanks...

    ReplyDelete
    Replies
    1. Yes sure, Connect the LED and buzzer to the pins- 13 and 2 of arduino. Then download and upload this code.

      Click here to download the code

      and also need to add two buttons to turn on and off the LEDs and buzzer in the bluetooth application in your phone with the commands Switch 1) Press test - V relase test - v , Switch 2) Press test - X release test - x

      Delete
  15. Can u tell me how finalcode.ino will work

    ReplyDelete
    Replies
    1. Which part of the code you need explanation?

      Delete
  16. for Bluetooth the robot not takes turn , when i press left button the wheels rotates in same direction ,this happens for obstacle avoidance also ....
    help me

    ReplyDelete
    Replies
    1. Is it is moving forward when pressing forward button? or turning round?
      If it is turning round on pressing forward and moving forward when pressing left then, reverse the connection of any of one motor. It may solve your problem.

      Delete
  17. yes it is moving forward and reverse by pressing reverse button .
    bt not takes turn left and right turn.
    its my final year project. i connected 12v car vacuum cleaner to it and i given the name as obstacle avoidance floor cleaning robot

    ReplyDelete
    Replies
    1. Try by changing the ports of the motor controller(the code I have provided here is using the ports 1 and 3) Try it by changing the ports to 2 and 4 (also make appropriate changes in connection of motors) if it is not work after that, check your motor shield by the example code provided in the 'afmotor' library.

      Delete
  18. Hey , can you please help me ? Im doing your project and i have made almost everthing , but i was just testing the bluetooth controled and my motors dont work i dont know why . I´ve made everthing just like you , but the motors just do a little sound and dont rotate . Even when i press reset on the motor shield it gives me the notice that its working on the monitor of the aplication . PLS help me

    ReplyDelete
    Replies
    1. Pls test your motor and motor controller separately before uploading the above code using AFmotor test code available in the "AFmotor" library.

      Delete
  19. hello.. can i know whether you use the exact motor shield as you put at 'where to buy'?

    ReplyDelete
  20. all type of l293d driver shield can be use right?

    ReplyDelete
    Replies
    1. No, The above codes work only with the adafruit motor shield shown in the parts list.

      Delete
    2. okay, thanks. is it the Qunqi L293D Motor Drive Shield For Arduino Duemilanove Mega UNO R3 AVR ATMEL that you state there can be use for this? i've found a motor driver shield exactly like this.So I am confuse whether it can be use or not.

      Delete
    3. yes, it may work with the above program.

      Delete
    4. okay thank you. one more question, can I use the 12v gear motor other than the picture's?

      Delete
    5. Yes you can. But not forget to consider the output amperage of the motor controller.

      Delete
    6. do I need to remove the jumper for l928n?

      Delete
    7. Hey it is in the case of l293d motor shield. Pls read the tutorial carefully before asking.

      Delete
  21. This comment has been removed by the author.

    ReplyDelete
  22. thank you for keep on replying my comment sir. my robot is working well when using the controller but there's some problem with avoiding obstacle and wall follower. from my observation, the sensor only detect twice. for example, at first, there is no wall detected but then it do not detect anything even though there's obstacle in front. Do you know why?

    ReplyDelete
    Replies
    1. Before uploading my code, pls check your each modules and sensors saperatly.

      Delete
  23. Buenas tardes, soy principiante con esto de Arduino y mi consulta es si puedo realizar el proyecto del ROBOT SEGUIDOR DE PARED, EVITANDO OBSTÁCULOS, CONTROLADO POR SMARTPHONE con una placa Duemilanove en lugar de Arduino uno, agradeceré su respuesta.

    ReplyDelete
  24. Hello Muhammed, could you please help me. I am doing this project using Adafruit Motor Shield V2 but your code was for Adafruit Motor Shield V1 and I am unable to update the code. Can you provide an update?

    ReplyDelete
  25. This comment has been removed by a blog administrator.

    ReplyDelete
  26. can i us bo motors for this project.can i use a motorshield other than from adafruit.what library should i use for this?

    ReplyDelete
  27. should i use the updated circuit or th old one.

    ReplyDelete
  28. hi , I am doing a school project. I have done up the hardware and successfully uploaded the code but it still doesn't work. The bluetooth and sensor work but my motors dont, any reason why?
    help. must it be a gear motor , what is a gear motor, is a dc motor ok?
    help help help asap

    ReplyDelete
  29. hello bro,
    my problem is that even after doing everything correct my geared motor is not rotating and its npt even vibrating can you please tell me is there any problem in coding or in my connections. if you have any other coding or suggestion then please reply me asap.
    thank you

    ReplyDelete
  30. Hello! Very interesting your project. I want to add two more ultrasonic sensors as in this project and have your bluetooth control as well:
    https://www.instructables.com/id/Obstacle-Avoiding-Robot-Using-Ultrasonic-Sensors/.

    I want to use stronger drivers like 2 x BTS7960. I build a lawn mower .... Thank you !!!

    ReplyDelete
  31. Hi, I did this as my first robotic project. But I always get an error.
    it says like this. I'm actually a beginner. Please Help me :'(
    Arduino: 1.8.10 (Windows 7), Board: "Arduino/Genuino Uno"

    Sketch uses 5050 bytes (15%) of program storage space. Maximum is 32256 bytes.
    Global variables use 483 bytes (23%) of dynamic memory, leaving 1565 bytes for local variables. Maximum is 2048 bytes.
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xa7
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xa7
    Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    ReplyDelete

Click on 'Notify me' to get replies of your comment.

Popular Posts

Like us on Facebook

Contact Form

Name

Email *

Message *