Exciting developments this week! First a photo:
I'm using the TV as a display for the Rapsberry Pi because the Pi conveniently has a composite video out. The white text onscreen the output of a python program that communicates with an Arduino Uno to read the value of the thumbstick controller's two potentiometers.
This is the little device I built. As I mentioned last week, the problem with the Raspberry Pi's input pins is that they're all made for digital input (either on or off). To read the full range of values that this thumbstick controller puts out, I need to use an Analog to Digital Converter (ADC) to transform the continuous sensor signal into digital data. I borrowed an Arduino Uno from Detkin because it has a built in 10-bit ADC. I wired up the thumbstick controller with little prototyping cables so I could use it with my breadboard and tested out on the Arduino - I wrote a little sketch that grabs the value of the thumbstick and prints it to the serial connection. It works perfectly!
The next step was to get the Arduino and the Pi to talk to each other. There are a lot of ways to do this (you can even use a USB cable from the Pi to the Arduino), but I chose to use the I2C bus. I2C stands for Inter-Integrated Circuit, and the bus allows microcontrollers to communicate with each other using only two wires - a data wire and a clock signal wire. You can daisy chain many microcontrollers through one I2C bus and address them each individually.
I wrote a program for the Arduino that continually reads the value of the sensor and stores it internally. It also has function that responds to an I2C request and sends the sensor data over the wire. I then wrote a python script for the Pi that asks for data over the I2C bus and prints it to the terminal. The drawback so far seems to be that you can only send data over one byte at a time. Since I'm using a 10-bit ADC, it takes two reads to get one axis' data. The communication system could be more efficient but it works for now.
The next step (my goal for alpha reviews) is to make this data drive a synth patch in Pure Data. Then we can really start experimenting.