Android controlled Arduino Bot
As the name says… this is a robot, me and a friend of mine (http://bytesandlogics.wordpress.com/2011/08/17/android_arduino/) attempted, which makes the use of the Arduino and the android platform. It’s a simple bot which has an arduino board, powered by the Atmega328 microcontroller, as the brain. However the microcontroller receives its command from an Android phone.
The inspiration for the project was to acquire the ability to affect the physical environment around us using a device to which everyone has access to ….Cell phone.
So….this is how it works..
The first stage of this project is to have a graphical user interface with which the people can interact. As the robot, at this stage, only needs to maneuver in two dimensions, the GUI is not as impressive as it would need to be for more advanced applications. Currently it is just a group of 5 buttons namely…front, back, right, left and stop.
The real action is however the one that cannot be seen. This was the tough part actually. Since none of us was well versed with java and Android programming, it took a fair amount of searching and learning in order to get the communication set up. Right now only the bare basics of communications have been included in the project.
When the application is run, it first checks to see if the Bluetooth on the phone is enabled. If not it asks permission to enable it.
Next the list of the devices with which the phone had previously paired with is presented. Since the app is in a very crude stage, the ability of searching for new devices has not been included.
Once the device is selected it establishes a link with it. Here the other device with which the phone communicates is my laptop. The laptop acts as a server and has a python script running which bridges the link between the Bluetooth and the USB serial port.
Once the link is established, the user can press one off the buttons to maneuver the bot. Behind every button click there is a listener which then takes a byte code representing that button and sends it to the server.
The server is a Python script running on the laptop. It is nothing but a tunnel which directs the input from the bluetooth to the serial port.
The server then forwards this number to the serial port.
The serial port has an arduino board attached to it which is further connected to the RF transmitter.
The transmitter was in turn attached to another arduino board. To work with RF communication we used the VirtualWire library which is very well documented and made the job really easy.
The transmitter then forwards this code to the receiver on the bot. On getting the data from the RF receiver the microcontroller calls upon the appropriate functions which set the inputs of the Motor driver ic L293D to HIGH & LOW values correspondingly to maneuver the robot.
As you might have noticed, we had to take the longer route here. Since we dont have a bluetooth module for direct contact with the arduino, we had to use the laptop as an intermediate (with the module the laptop wont be required at all).
The idea can be used to control multiple devices (fans, lamps, windows, ovens etc…) using a single interface on your cell phones.
In order to accomplish, there needs to be a central node with which the cell phone interacts. This node takes the input from the user forwards it to devices to which the commands are relevant.
To take this one step ahead, the concept of Virtual Private Networks can be used in which a client can remotely access the server using the internet Infrastructure. Since almost all the smart phones at present are internet enabled, a server at home can get commands from a user at a distant location and carry out the necessary actions (…ever forgot to turn off the stove while on vacation ??)