Control our Etch-A-Sketch with Twitter!
We've used an mbed Microcontroller to hook up an Etch-a-Sketch to the Internet, and it's listening out for your tweets to @mbedmicro to tell it what to do!
| Live Stream: | YouTube Video: |
How can I control it?
You can control our Etch-A-Sketch by twittering commands to @mbedmicro!
It understands the LOGO language, so you can control it just like it was a turtle. For example, some basic LOGO might look like...
@mbedmicro FD 50 RT 120 FD 50 LT 90 BK 50...and a more advanced command might look like...
@mbedmicro REPEAT 3 [ FD 100 LT 120 ]...but that is just the start. Why not see what others have found out. Then try it yourself!
How it works
So how exactly does the mbed let you command an etch-a-sketch, in LOGO, via twitter?!
The Hardware
We used the mbed Microcontroller's built in ethernet interface to talk to the internet, and added the electronics and hardware rig to allow it to twiddle the etch-a-sketch knobs using robot servo motors...
We took an original Etch-a-Sketch and bolted on two Dynamixel AX-12+ Smart Servos, using a metal plate to hold them in position. These are connected to the mbed as a daisy-chain via a line driver, and are controlled by a half-duplex serial signal generated by the mbed. These motors are great once you have control of them.
And to allow it to be receive commands from the internet, we just have the mbed's ethernet port wired up to the nearest connection. As a bonus, we threw in an LCD too!
The Software
The job of the software running on the mbed is to poll a server on the internet for LOGO turtle commands to execute, and turn that in to low level commands to control the motors. It is achieved by plumbing together a load of libraries, and here is how it works...
An HTTPClient object is used to poll a server with an HTTP GET request to see if there are any LOGO Turtle commands to execute. Basically:
char commands[1024];
http.get("http://server/logo-commands", commands);
If there are any, it'll get a response body with the commands to execute. Something like:
FD 100 RT 90 FD 25
We then work through this list, turning these commands in to a vector (direction, distance) that it is passed to the EtchASketch class. Its job is to convert that in to commands for the AX12 motor classes (speed) and the time to run them for, using some basic trigonometry. So you end up with something like:
xmotor.speed(x); ymotor.speed(y); wait(t); xmotor.speed(0); ymotor.speed(0);
And of-course the AX12 classes know how to turn the speed requirements in to commands to send over the serial bus to the servos.
Phew, and we're there - Internet LOGO commands to commanding digital servo motors in a few steps. All made possible by software abstraction!
The Server
The server is in charge of looking for twitters that request the etch-a-sketch do something, and run a LOGO interpreter over them to convert them to raw LOGO turtle commands...
The server polls the twitter API looking for tweets @mbedmicro. If it finds some, it passes the contents through a LOGO interpreter to turn them in to low-level LOGO turtle commands that can actually be drawn (e.g. FD, RT, ...). These are ready to be sent when the etch-a-sketch requests them.
And for those of you still paying attention, here are some cool tips:
- If the twitter contains a LOGO function definition (and therefore no output is generated), it is added to a list of functions. And they can be used by subsequent tweets :D
- If you follow @mbedmicro, the server will direct message you to say whether your LOGO commands were accepted, and if not, why not. Debugging via twitter too :)
Why build a twitter controlled LOGO enabled Etch-A-Sketch?
So why did we build this?
1. Because you can! Etch-a-sketch is cool, and we thought there must be a good use for twitter.
2. Because the LOGO Programming Language was so influential. This was the first exposure many people would have had to programming way back when, and Seymour Papert's work such as Mindstorms - Children, Computers and Powerful Ideas spotted the importance of the technology in it's infancy, and showed how it could be a great teaching tool. We wouldn't be where we are today without LOGO! And yes, that is how LEGO Mindstorms got it's name!
3. To show microcontrollers can now enable an Internet of Things! A microcontroller is basically a full computer inside a very tiny chip, but designed specifically for controlling things and to be very low cost. You never really see them, and up until now they've been used for controlling the ABS brakes on your car, the motor in your washing machine, and lots of other things that can be better with some built in intelligence.
But in the future it won't be just PC's, laptops and phones that'll be using the internet. Soon it'll be an Internet of Things, when devices themselves start talking on the internet to help do things better. No humans involved! As the mbed microcontroller can connect directly to the internet, it's great for prototyping new ideas that could be the revolutionary products of the future!
4. As a rapid prototyping test! The mbed tools are designed to help you prototype quickly, so it is always good to eat your own dog food. We started putting it together on thursday, and it had to be finished by the end of Friday ready to hitch a ride to the US. Nothing like a deadline to focus the mind :)
Disclaimer: whilst we had it working on Friday, we also had to do a bit of last minute modifications on Saturday. The motors are pretty high torque and we ignored the end stops; a high pitched "plink" indicated this was not an acceptable solution :P Time for a new etch-a-sketch and a little extra logic!
More about mbed
mbed is a tool for Rapid Prototyping with Microcontrollers.
It takes a cutting edge ARM Cortex-M3 microcontroller, packages it in a DIP form-factor for easy breadboarding and experimentation, puts the tools online so they "just work", and gives you high level C++ libraries so you can get control of the interfaces straight away.
The aim is to get you started and help you build your prototypes as fast as possible.
For more information on what mbed is and how it can help you, take a look at the tour:
To get your own, visit the ordering page to find your favourite distributor: For more background information, photos and contact details, see the about page:



