Let's Make Robots!

iPhone Wifi controlled RC car

It's controlled via iPhone

Most of this is described about in the video however this is a little more indepth and more story driven. My first 'real' project, and first post on LMR.

The basis of the robot is an Arduino Uno with an Adafruit motor driver shield. I de-soldered the leads from the power supply and motors on the car and attached them to the motor shield. I programmed the the motors to respond when they received case letters over the serial port example: case 'a' motorSteer blah blah. Testing the car was simple, just had to open the serial monitor and type the letter in and hit enter and the motor moved, however, the next part was harder.

As I wanted the car to be controlled by my iPhone over Wifi like those fancy remote control cars you see in the shops I needed to find a way to send information from my iPhone to my computer and then to the Arduino. Luckily I found a project on YouTube similar to what I wanted to do which used the app TouchOSC.

TouchOSC is meant for DJ's who want to control their rigs or whatever using their iPhone. The user can make thier own custom layouts and name the buttons and sliders and such and give them values such as minimum and maximum. The app sends UDP packets containing the information about what user touched and what the value is to a chosen IP.

Knowing this I searched the internet for ways to read UDP packets from iPhone on my computer and I came across Processing. Processing is an open source software creator basically which allows users to program their own programs and such. Spending a few hours with the program I learnt how it all worked (luckily the syntax is very similar to Arduino IDE, and after which I found out that the Arduino IDE is written is Processing, win) and installed libraries to read those UDP packets.

So basically now what I had was iPhone sending packets of information to be received by Processing but then I wanted that to be sent to the Arduino. More googling found Arduino libraries for Processing that allowed me to write bytes to the serial port, this was exactly what I needed.

After some more work I finally got it all to work, iPhone sends data, Processing interprets data and sends information to the Arduino through the serial ports, Arduino reads the information and responds accordingly.

Sorry if the explanation was not the greatest and I'm definitely not the greatest person out there to talk about this stuff but I hope you got something out of this because I certainly did. After I finish my Year 12 exams I will definitely investigate Processing much more and how I can bridge connections between various peripherals and the Arduino. Thank you for reading. I now realise how big that all is and apologise for the wall of text. :)

UPDATE:

If you wish to do something similar I have provided the code below;

Arduino code for car: https://www.dropbox.com/sh/3hlx7aii9jceirw/7S74vcXyye

Processsing code: https://www.dropbox.com/sh/ounfzxrp0lzkoxi/pkJFZafuJ9

And the download link for the app I used;

TouchOSC: https://itunes.apple.com/au/app/touchosc/id288120394?mt=8

I have tried to comment the code to the best of my ability. I am by no means the best programmer in the world infact I am probably the worst, if there is a way to make the code more optimised or something let me know how I can fix it and I will update the files for everyone.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks for this post!  We were able to reproduce a similar result, but we used an IOIO board instead of an Arduino.  Here is the prelimenary result:

http://youtu.be/qfeAFhPt2zg

As LMR is experiencing difficulties currently displaying videos here is the video link: http://www.youtube.com/watch?v=NI3ynFfZQQc&feature=plcp

Looks like you learned a lot on this project - build, motor control, UDP, reading and interfacing Pc to Arduino and more. If the iPhone app could read an webcam image and display it on the screen it would be a little telepresence setup.
Good job
Stephen

Yes this was definetely a big step from me working with cardboard and little servos! Ive kept it so I can later try to work out how to do that exact thing, but probably on the computer instead, so the whole control scheme and wireless webcam image would be seen in a browser or something. Thanks.

On my LtBot2 I just use LogMeIn to remote into the netbook and control a Just Basic app that does the controls. http://letsmakerobots.com/node/34323
Quick, simple, and free for personal use. You could use VNC or something but would have to open ports on your router or VPN back into your network to make it work.
Sounds like you gphave about everthing you need there already to control it.
I code write a lot of old time ASP web code and wanted to control the bot that way as well but you really need local java or something to keep the controls responsive enough IMHO.
Stephen

Thats a really nice bot you have there! I like the idea of using that software, I think remoting in would be the best option. I have a weird router that has been made especially for the type of internet im on and there isnt much of a presence of it on the net and forwarding ports on it can be a real pain in the butt. Thanks for that.