Symbolic programming of Arduino devices in Mathematica
To give you a better idea of what this is, I thought I'd preface this post with a video I took of my robotic turret pointing a laser pointer. At about 1:45 in the video I start talking about the technical details, so if that doesn't interest you, skip ahead to the rest of the post.
What is an Arduino
An Arduino is a cheap, powerful tool for prototyping electronics quickly and efficiently. They can be used for any number of things, from building simple circuits to light LEDs and do simple on/off actions, to robotic turrets and full-scale robots that can move, talk, and think. They come in a variety of sizes, shapes, and power, from the ATtiny, a $2.50 IC, to the Mega, with over 60 I/O ports. The board I use in the video is called the Uno, and it's just the right size and has enough port capacity for pretty much any application.
Arduino microcontrollers are essentially cheap, simple ways to integrate electronic control into everyday things. Jarvis could easily be created with an Arduino board hooked up to a bunch of relays that turn AC power lines on and off – you'd still need the voice recognition on the computer, but an Arduino would be a cheap replacement (about $80 cheaper) for the expensive web power switch. The DIY website instructables.com has thousands of Arduino how-to's, from making gardening robots to 3D LED cubes. The best part about using Arduino boards with electronic hardware is that everyone is doing it, so there is a huge community to provide ideas and help to novices and experts alike.
Controlling Arduinos with Mathematica
The video is a demonstration of a package that I developed for Mathematica called ArduinoLink. I can't release too many details about the package just yet, but what I can say is that it will soon be available (for free) to all Mathematica users. It uses symbolic code generation, context prediction, and low-level backend functions to vastly simplify programming and communication with Arduino microcontrollers. The entire video demonstration above was programmed with about 10 lines of Mathematica code.
Consider this – to program the same demonstration in C would take hundreds of lines of code, because one would need to hand code a scheme to get the webcam image, process it, pick a center point, and send a serial message to the laser pointer to move to that point. Using Mathematica, I just need to pass the result of the function
CurrentImage into the
ImageComponents function, which returns me the centroid of objects in the image. Everything else in the process is about that simple – delegate all major tasks to external functions, then build useful chains out of them. The thrill from doing complex things with simple commands is one of the main reasons why high-level programming is so addicting.
Check it out
If you've ever wondered what lays beneath the fog that enshrouds the hardware realm, Arduino's are your way in. They are an awesome way to learn about electronics, and they are remarkably useful for many projects that will undoubtedly pop into your head when you realize the possibilities. There are tons of resources online to get started, but the best one is the Arduino homepage. The boards themselves are cheapest on Amazon, and you probably want to find a local electronics store for parts. Good luck and happy prototyping!