Control your R/C vehicle from your iPhone
And just like that… the jitter’s gone!
I’ve made a few modifications to my Arduino sketch to keep it small… and I’m happy with it! I’ve learnt that the smaller the footprint on a device with limited memory the faster it can process things. So I’ve gone from an Arduino Sketch of roughly 100 lines of code… to something so slim and simple that it almost feels wrong to use it! Below is the graph from the output of the serial socket…
I’m releasing this code… now… I’m feeling a little nervous about releasing it… If you’re going to copy and paste this code, could you please at least leave the credit at the top? I’ve worked hard on this, and I didn’t do it so some twat can steak his claim on my work!
That’s right, no advanced algorithms, no crazy conversions, I’m just taking the first 3 bytes of the buffer from the socket and assigning it to the acceleration, and the last 3 bytes and assigning it to the steering… There are no heavy HTTP protocols to handle the requests, just one socket stream connection from the iPhone to the Arduino/BlackWidow! I can’t believe that the last 4 months of R&D has led to 8 lines of code!
Just to show you what I mean, the sketch started out like this…
Which works fine if you’re not trying to push through 60 requests per second to a device with 2 KB of SRAM and 1 KB of EEPROM. Just to put it into perspective the iPhone 3GS has 256mb’s of RAM…
Update… sorry guys, I’ve taken the code down… for now! I’ll put it back up once I’ve made my mind up about how to distribute it!
| Print article | This entry was posted by admin on March 9, 2010 at 11:13 am, and is filed under Communication, Wireless, sockets. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |


about 2 years ago
Out of curiosity, are you going to be posting code? It would be extremely helpful for the rest of us! (either iPhone or Arduino code… or both!)
about 2 years ago
Good work man, are you still thinking of distributing the code under license?
I’m mostly interested in the sockets communication parts of things.
cheers
about 3 years ago
Awesome code reduction man! I’m getting my Black Widow and a liPo battery in the next few days. Then I’ll rip off your code and become famous!!
Just messing with you. totally sexy strip down. way to go.
about 3 years ago
Haha, you better not! There’s nothing I can do really other than complain! Thanks Buddy
about 3 years ago
I’m liking your code shrink, have you thought about using iOSC on the iPhone/iPod Touch and using WiShield/Black Widow to decode the response instead of starting an app from scratch.
Either way you go, I’m still going to be impressed.
Keep it going.
about 3 years ago
I’d had a look at this, there are a few projects out there using this at the moment, but I found that iOSC was quite limited. Writing it from scratch allowed me to make a much more responsive car, so there’s next to no lag between the car and the iPhone! Thanks for the heads up though I appreciate it!
about 3 years ago
I expect a test video now, another that makes me laugh for a different reason – its all that keeps me sane at the moment!
Jokes aside, really good work mate – can’t wait to see the working product and have a play!
about 3 years ago
Cheers Dave,
Lol a video will be posted shortly, I’m just eagerly awaiting the post man to deliver my Lithium Ion battery today so the Arduino doesn’t keep cutting out when it’s not connected to a regulated power source.
Well I’m planning to have a closed beta for IMPs around the 7th of April in the Sports hall at uni to get some user feedback so I’ll put you on my list.