Thursday, April 8, 2010

What is the TouchShield Slide?

Recently, I've been getting a lot of questions from folks asking about the TouchShield Slide. What is it, how does it work, and how does in talk to the Arduino?

So here's a quick run-down for people who are just finding it for the first time:

What is it?

The TouchShield Slide is a shield for the Arduino. It has a really bright OLED screen on the front, and it has a touch-screen pad on top of it, that allows you to create interfaces, and physical computing GUI's with it. Chris and I made the TouchShield Slide about a year ago to experiment with GUI's and gadgets, after being inspired by the large number of emerging modular gadget platforms that were springing up, and deciding that it was time to upgrade the TouchShield Stealth, which was the original DIY OLED screen we built a while back. At the time, Chris and I thought, modularity is pretty cool, why not bring it to the Arduino platform?

It's been available for sale for some time at a number of web shops and stores, including Since then, people have built games (like Ping Pong, Mario, Asteroids), put it into gyms to make it record data and data log exercise, digital sticky notes, Digg buttons, and built operating systems.

Naturally, there are a few undocumented easter eggs hidden on the TouchShield Slide too :-)

How does it work?

The TouchShield Slide snaps on top of the Arduino, Duemilanove or Mega, by slotting into the pins on the digital side, analog side, and power port. The power pins provide voltage to the shield, and power the OLED screen. The Digital pins allow the Arduino to send and receive serial commands to and from the TouchShield Slide. This is helpful, for instance, if you have a sensor connected to the Arduino, and you wanted to send the values of the sensor to the TouchShield Slide to display as bar graphs.

Controlling OLED's is not an easy thing to do, and in fact, if the Arduino were to try to control an OLED directly by itself, it would basically use up all of the programming capability of the Arduino, and leave no computation left over to do anything else (like poll sensors or blink LEDs or read switches). So to ease the load on the Arduino, the TouchShield Slide has it's own processor on the backside that basically acts as a graphics processor. It takes over all the heavy duty processing from the Arduino, and leaves the Arduino untouched (or at least very minimally touched).

How do I program it?

The first thing to understand is that you have to program the TouchShield Slide separately from the Arduino. That means, you place the TouchShield Slide on top of the Arduino, and then you download the IDE for Windows here or for Mac here.

This IDE is called the "Antipasto Arduino IDE", and is specially updated from the original Arduino IDE to allow code to be written and programmed and downloaded to the TouchShield Slide. Here is a sample "hello world" program for the TouchShield Slide:

void setup()
background(0,0,0); //this paints the whole background black
stroke(0,0,255); //the outline of the next shape I draw will be blue
fill(0,0,255); //the inside fill of the next shape I draw will be blue

void loop()
gettouch(); //find out where a finger is touching
ellipse(mouseX, mouseY, 3, 3); // draw an ellipse(x, y, width, height)

Pretty basic, but you can see that since the TouchShield Slide is a graphics shield, Chris and I ported the Processing Graphics programming language to it, so you can program it just like you'd program Processing.


After you compile the code above (which is a lot like how you program code for the Arduino, except you just have to select "TouchShield Slide" from the boards menu), and plug in the USB port from the computer to the Arduino, you then have to press the tiny little button on the side of the TouchShield Slide, which "resets" the shield, and puts it into a mode of waiting for code to come from the PC. The you press the "program" or "download" button in the Arduino IDE, and the code gets downloaded to the Slide. When it's done downloading, the TouchShield automatically resets itself, and the program you wrote starts running.

How does it talk to the Arduino?

The TouchShield Slide has a set of functions built in to it that make it easy to send data back and forth between the TouchShield and the Arduino.

A quick side note, iamshadowlord has written a nice tutorial on this, which goes into more depth, over here. (Thanks!) For advanced programmers, this is a good example of how to send data back and forth!

So I've tried to simplify it for beginners a little bit by making a simple "HardwareSensor" library that now dramatically simplifies the interface between the Arduino and the TouchShield Slide. It's called HardwareSensor, because I got so many emails from people asking, "How do I send sensor data from the Arduino to the TouchShield Slide?". This is how (here's the link for the reference docs):
On the Arduino, you put this code:

void setup() {

void loop() {
int value = analogRead(5);
Sensor.print("accel", value);

And on the TouchShield Slide, you put this code:

void setup() {

void loop() {
if (Sensor.available()) {
int value;

value =; //get the sensor value
text(value, 50, 10); // print the value to the screen
text(Sensor.getName(), 10, 10); // print the name to the screen

In the coming days, I'm going to be writing a LOT more about the HardwareSensor library, and how you can use it to make physical computing GUI and graphical displays... here goes nothing!


JustinN said...

I'm going to try this soon. So, exited about it. I could never get the arduino and ts to talk to each other reliably. Maybe this will fix that.

the robotmeter guy

JustinN said...

Ok, testing things out. How do i pass multiple sensor values and "dereference" them when they pop up on the touchshield?

I know there is "Sensor.getName()", but it doesn't return a string, it returns a pointer. So I guess this is how it should be done...

Eric Anderson said...

I'm a noob and confused about how to program the the TouchShield. Does the TouchShield have its own Integrated Devlopment Environment or does it share the Arduino IDE? The link in the article leads to a page that says its no longer on the liquidware site. I'm doing some preliminary research before I buy.

Marc Price said...

Has anyone out there tried comms in the other direction - ie the TouchShield sending data to the arduino?

I can't get it to work. I can get the simple example given to work, but if I do a role reversal, with the shield sending data to the arduino, the arduino blocks at Sensor.available(). I'm wondering if there is a bug in the available() method that only shows on the arduino?

Nimble Blimp said...

I'm guessing that it just uses pin 0?