Wirelessly Control A Robot Using Arduino and RF Modules !

Written by: gadgetguru

Edit 05/05/2016

Hey guys, I've been busy with college and couldn't reply to commments. Most of y'all wanted the code and schematics done a bit better so I've made the schematics on Eagle 7.2.0 and uploaded everything on Github.

Here's the link : https://github.com/r5sb/Wireless-Arduino-Robot.git

Cheers!

*/

In this Instructable you'll learn how to make an RF controlled Arduino Robot.....or in other words your very own Minion waiting to obey your commands..... :p

OVERVIEW 

In this project I've used a 433Mhz Tx and Rx pair to allow the Arduinos to communicate wirelessly with each other.These modules are probably the easiest way to set up wireless simplex communincation between two arduinos and are much cheaper compared to other wireless modules like Xbee or bluetooth modules(reduced range though).

I have shown two alternatives for controlling the robot :- 1). Using your computer's keyboard to control the bot and 2).Using a separate controller made on a breadboard.
The robot uses differential drive in order to turn (wheels on either side move in opposite directions).

Refer to the pdf attached for getting started with these modules.

So lets get started..... :)

    Step 1: Collect Your Parts

    Here is the parts list and some links for buying them :-

    The Controller Board :-

    1. Any model/clone Arduino board.
    2.The 433MHz OR the 315MHz module (both work the same way) Tx and Rx pair ( Link here)
    3. A breadboard for the controller pad (Not needed if you're using a computer to control the bot).
    4.Push button switches X 5 (Again not needed if you're using a computer to control the bot).
    5. Connecting wires.
    6. 9V battery to power the Arduino on the Tx end.
    7.A 17cm long breadboard wire for the Antenna for the Tx and Rx.

    The Receiver Board :-

    1. Any Arduino model/clone board.
    2. The Rx part of theTx/Rx pair (Link in Step 2 above).
    3. Breadboard and connecting wires.
    4.12V battery pack to power Motors.(In the video I have used a 12V AC to DC adapter)
    5. 100uF Electrolytic Caps X 4.
    6. L293D motor driver chip X 2 (Each chip controls 2 motors bi-directionally...So if you want to make a 2 wheeled bot you will require only 1 L293D chip).
    7. 0.1uF ceramic caps X 12 (3 for each motor)....for eliminating noise between the controller and motors.
    8. A 9V battery for powering the Arduino on the Rx end.

    Note :- You can skip step 5 and 6 if you have a motor shield...though the code will need some tweaking then!

    Robot Chassis and Drivetrain :-

    1.DC Motors X 4
    2.Robot chasis
    3. Wheels X 4

    Note :- I used this robot chassis....came with the motors and wheels 

    Now on to the build......
     

    Step 2: The Transmitter : Part 1 :- Controlling the Robot using the Computer

     

    The transmitter and receiver communicate across a  433MHz frequency ( or 315MHz...really depends on what module you use).

    The transmitter is the smaller module having 4 pins :-

    (1)Ant ---------> Antenna
    (2)Vcc ---------> Power supply....in this case 5v from the Arduino at the Tx end.
    (3)Data -------> Data pin.....transmits the data in bytes.
    (4)Gnd-------->Ground pin....connected to Arduino ground.

    First solder the 17 cm (about 13cm for the 315MHz module) solid core breadboard wire to the Ant pin on the Tx module....the added antenna increases the communication range and improves performance indoors.
    If you do not want to solder the antenna directly you can  always connect it on the breadboard.

    In this step you will learn how to control the bot using the computer.

    You can have a look at Step 3 which shows how to control  the bot using a breadboard controller.

    Connections :-

    These are the connection between the Arduino and the Tx module.

                               Tx                                                Arduino


                            Vcc----------------------------------->  5v pin
                           Gnd-----------------------------------> Gnd pin
                          Data-----------------------------------> Digital Pin 3 

    Code :-

    First you need to download the VirtualWire Library...this library makes coding these modules for the  Arduino very easy.
    Download and Installation instructions are provided here

    Working of the code :-

    The code accept inputs from the user (f,b,r,l,s)  through the serial monitor and then uses Switch-Case statements to determine which command is to be sent by the Tx .i.e. Front, Back, Left, Right, or Stop.

    The code is attached below in a .txt file.....just paste it into a new window on the Arduino IDE.

    Moving on......
     

    Step 3: The Transmitter : Part 2 :- Breadboard Remote Controller

     

    This is an alternative way of controlling the bot....by building your own remote on a breadboard.

    This is where the push buttons come in use...connect the push-buttons in a way that you find comfortable to control the bot (see the pics for reference).

    Make sure you identify the correct terminals of all the switches.

    The Connections :-

    Connect one terminal of each switch  to  a common ground that is connected to an Arduino ground pin (Again refer to the pics).

    Connect the other terminal to a Digital pin on the Arduino.

    The connections should be something like this :-

                                               Button                                                            Digital Pin

                                           Forward ------------------------------------------->     08
                                          Backward ------------------------------------------>    09
                                          Right        -------------------------------------------->   10
                                          Left            ------------------------------------------->   11
                                          Stop         -------------------------------------------->   12


    You can change the digital pin connections....but make sure you change them in the RemoteTx code as well!!

    The Code :-

    (1) The Tx Code :-

    The code reads whenever a button is pressed since the corresponding digital pin goes LOW.Based on which digital pin goes LOW the appropriate command is transmitted.

    (2)The Rx Code :-

    The code receives the transmitted byte and based on the command received move the bot in the desired direction.



    Both codes are attached at the bottom.

    Step 4: The Receiver

     

    The Rx is the longer module having 8 pins :-

    (1)Ant
    (2)Gnd
    (3)Gnd
    (4)Vcc

    (5)Vcc
    (6)Data
    (7)Data
    (8)Gnd

    Note :- we only use the first Data pin (pin 7).

    Now take the second 17cm wire and solder it to the Ant pin of the Rx module.

    Connections :- 

    These are the connections between the Arduino and the Rx module.

                                 Rx                                                Arduino


                            Vcc----------------------------------->  5v pin
                           Gnd-----------------------------------> Gnd pin
                          Data-----------------------------------> Digital Pin 2


    You will also need to connect the two L293D motor driver chips to the Arduino at the receiver.( Pin diagram of L293D given in the pics) Make sure you connect the chip properly...the end with the notch is the front end.

                              First L293D                                           Arduino

                                 Enable1 --------------------------------> Digital Pin 05
                                 Enable2  -------------------------------->Digital Pin 06
                                 Input 1     -------------------------------->Digital Pin 07
                                 Input 2 ----------------------------------->Digital Pin 08
                                 Input 3 ----------------------------------->Digital Pin 09
                                 Input 4 ----------------------------------->Digital Pin 10



                                  Second L293D                                           Arduino

                                 Enable1 --------------------------------> Digital Pin 03
                                 Enable2  -------------------------------->Digital Pin 11
                                 Input 1     -------------------------------->Digital Pin 04
                                 Input 2 ----------------------------------->Digital Pin 12
                                 Input 3 ----------------------------------->Digital Pin 14(Analog 0)
                                 Input 4 ----------------------------------->Digital Pin 15(Analog 1)


    Additional connections :-

    (1)For the L293D motor drivers :-
    Pin 8 of both the L293D chip go to the poitive of the 12V supply....this pin gives the power to the motors.

    Pins 4,5,12,13 of both chips go to ground.

    Pins 3 and 6  are connected to the leads of first motor........and pins 11,14 go to the leads of the second motor.(Same for the second L293D as well but for third and fourth motor).

    Pin 16 of both chips is connected to the Arduino 5v supply...............this pin powers the chip.

    Very Important  :- Make sure Arduino and 12V  supply grounds are connected  TOGETHER!!!!


    The Code :-
      

    This code is receives the transmitted commands from the Tx and moves the robot in the desired direction.

    Note :- This receiver code is used when the robot is controlled via the computer input. Another modified receiver code is used with the breadboard controller and can be downloaded in Step 3.
     

    Step 5: The Chassis and Drivetrain

     

    Now get your Motors and robot chassis ready....

    First solder the 0.1uf ceramic caps on the motors in the following way :-

    (1) connect one capacitor across the terminals of the motor.
    (2)connect one lead each of the 2 other caps on the motor body and the other lead to each motor terminal.
    These caps don't have polarity so don't get worried about connecting them wrong.

    You can refer to the pics and also to the link for more help :-
    http://www.pololu.com/docs/0J15/9

    Now attach your motors to the chassis and connect the motor terminals to the correct pins on the L293D motor driver.

    Don't forget to connect the 100uF electrolytic caps to the supply pins of the L293Ds (Pins 8 and 16).
    Electrolytic caps are polarized and  need to be connected correctly.The shorter lead (the side of the casing with the strip ) is the negative terminal and the longer lead is the positive one.These caps smooth out voltage spikes from the supply.

    Now for the main assembly........
     

    Step 6: Main Assembly

     

    First make sure all the circuit connections are correct, caps  on the motors are soldered well and check for any loose connections.

    Be Careful While adding the batteries and make sure ALL connections are correct before connecting the batteries and powering up.

    For mounting the the receiver breadboard on to the robot I used bits of velcro. I secured the Arduino on to the robot by  using a zip tie.

    Use small bits of solid core wires or rubber bands to tie the different bunches of wires to make it a bit neater.

    Now on to Testing!!!!!!!!!!!
     

    Step 7: Test It!!

    With everything assembled and all the wires connected properly the only step left is Testing!

    Before you put the wheels on and power the bot  up.....test  it  without the wheels attached first...this way you can make sure all the motors have been connected correctly with the motor driver and their direction of rotation is correct.
    Once you're satisfied with the speed and rotation of the motors put the wheels on!
    Be careful when using the 12v supply and double check all your connections before powering anything up again!
    I have attached links to  videos of the robot testing when  controlled by both the computer and the separate breadboard controller.

    Now that your robot is made add some more features to it (I'm planning on tank tracks!)...now your bot is ready to do your bidding! :p

    Initial Test Video :-

     

    PS :- I have entered this Instructable in the Microcontroller Contest...so please vote if you liked it...Thanks!


    Update (28-10-13) :- Here is a short  video of the robot in action with batteries.....sorry for the bad shooting, had the controller in my other hand!

     

    Leave a Reply