showcontroller

Download the showcontroller project v0.8

Update, June 29, 2008: Linux users, see "one last note," near the bottom of the page, with editing instructions. I'll be modifying the source to auto detect mac or linux and choose the correct connection later (version 0.9...)

showcontroller is an extension of the socketserver project and the arduino project. socketserver is my solution to getting applications and devices to talk to one another; one of the things I wanted to be able to talk to was the arduino board, as they are cheap, opensource, and very easy to program and connect hardware to.

From the arduino homepage:

  • Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

In the spirit of 'easy-to-use,' showcontroller attempts to make a generic input/output system that readily connects to Flash, Director, Processing, or any other TCP/IP-enabled content creation platform. At present, it has 6 digital input/outputs (can be used for input, output, or input/output simultaneously), 2 digital encoders (non-indexed), and 2 analog inputs. I've come up with a very, very compressed protocol for arduino to my client software (socketclient.sh, in the download), so every 30th of a second the client checks in with arduino and arduino lets the client know what's happened since they last chatted. The client also allows setting of outputs, because they would be useless without that functionality!

Here's an overview of the protocol between your client software and the socketclient.sh program (from socketclient.sh comments, by the way...):

  • Network messages to this client:

    • ard:1:I sets IO1 to input mode (also works for 2-6)
    • ard:1:O sets IO1 to output mode (also works for 2-6)
    • ard:1:H sets IO1 output to high (also works for 2-6)
    • ard:1:L sets IO1 output to low (also works for 2-6)
    • ard:1:IO sets IO1 to input/output mode (also works for 2-6)
    • ard:1:R replies with input state of IO1 (also works for 2-6)
    • ard:A1:R replies with input state of Analog In 1 (also works for Analog In 2)
  • Network messages from this client:
    • En1:[value] broadcasts current value of Encoder 1 (happens on change of encoder reading)
    • En2:[value] same as En1 but for Encoder 2
    • An1:[value] broadcasts current value of Analog In 1 (happens on request for analog reading)
    • An2:[value] same as An1 but for Analog In 2
    • In1:H (or In1:L) broadcasts IO1 input state (happens on change of IO and in reply to ard:1:R; In2 through 6 are the same as In1 but for IOs 2-6)
    • In1:P broadcasts IO1 press event, or pin grounded (also applies to In2-6)
    • In1:R broadcasts IO1 release event, or pin not grounded (also applies to In2-6)

I'm versioning this as 0.8 instead of calling it good because I've only done a few days of testing on it. It feels close to done, but I want to include auto-detect of the usb-to-serial connection before I'll really be happy with it. By the way, since that's not written yet, you will likely need to change lines 92-93 of socketclient.sh to match the name of your virtual file to arduino. Here's how to do it on a mac:

  1. Open Terminal, located in Applications/Utilities
  2. Navigate to /dev ('cd /dev').
  3. Look for a name something like cu.usbserial-A####sSV.
  4. Insert that name into lines 92 and 93 of socketclient.sh
  5. All set... launch socketserver.sh, open another terminal window, launch socketclient, and you should be in business. (You did program the arduino with showcontroller.pde already, right?)

Oh, one last note... the arduino code doesn't care what OS you are running, but the client software is written for Mac OS X. That's probably another good reason for a version number of 0.8 and not 1. I've had this same script running under XUbuntu, so I know it will work, but I think I overwrote that file when I had to install Windows on my Linux box for testing hardware. It's only a few lines, probably the 2 commented-out lines (94 and 95). Uncomment these if you're running linux and give it a try.

Update: comment out lines 92 and 93 (mac serial connection), uncomment 95/96, and change 96 to say "stty -F /dev/ttyUSB0 115200 cs8 cread" and you should be good to go...

So goals for version 1.0 are:

  1. Windows/Linux support
  2. auto detect arduino
  3. possibly support multiple showcontroller arduinos plugged in at the same time

Download the showcontroller project v0.8