Raspberry Pi i/o

Raspberry Pi can easily interface the world via its GPIOs handling digital signals. Whats missing is analog input and output to process signals beyond on and off.

One easy and cheap way is to add a converter chip like the MCP3208 which converts 8 analog signals to digital information and talk to Raspberry Pi via the GPIOs. Actually the interface is SPI which is embedded in the GPIOS. The Raspberry Pi provides a reference voltage of 3.3v and the changes are measured on the IC and converted to numbers with 4096 discrete steps which is 12 bit. There are also version with different, less amount of inputs available and also a 10bit version, the MCP3008 which you find more often mentioned online but not so much in the stores anymore, at least I had problems to find it. Both are electronically compatible, its only the bit depth and therefor the number range which differs. So schematics for the MCP3008 works also for the MCP3208, only on software side you have to change the number processing. Thats why I had to create in my case a new Pure Data external because the existing PD wiring Pi only addresses the MCP3008.

Here is a schematic for using the MCP analog to digital converter IC. Its made with Fritzing and I found only the MCP3008 in their library but it stands in for the MCP3208 which is dropin compatible anyway. On the first input channel of the converter a potentiometer is connected. It get its reference voltage from the GPIO like the IC itself. Important is the third connector going to GND, otherwise with full resistance it would leave the input pin of the IC in an open, dangling state and it start to sample noise (which is on the other hand a very good, true random generator). 

This diagram (disclaimer: the schematic is provided as is, no guarantee is made that its faultfree, stuff is not burning or the cat is not being shot) wires everything up to use hardware SPI bus, which needs to be enabled in raspi-config. There is an alternative software SPI bus and schematics for that are online which tricked me, its a different setup but didn't worked for me because I needed the hardware SPI way.
With this you are good to go and can use the input with C, Python or Pure Data.

The new Pure Data external handling the MCP3208 input can be find at

Its tested with a current Raspberry PI 3 with current firmware and Raspbian. It is to be compiled directly on the Pi and uses the Wiring library to communicate with the IC via hardware SPI, which needs to be enabled with raspi-config first. Pure Data doesn't need to be run as superuser anymore unlike in former versions, but there are other reasons to do so, i.e. to have the -rt sound options for lower latency handling.