Created by Mikey Sklar
Guide Contents Guide Contents Overview Connecting the Cobbler to a MCP3008 To follow this tutorial you will need Why we need an ADC Wiring Diagram Necessary Packages Python Script Run It 2 3 4 4 4 5 7 9 12
© Adafruit Industries
http://learn.adafruit.com/reading-a-analog-in-and-controlling-audiovolume-with-the-raspberry-pi
Page 2 of 12
Overview
Teaching the Raspberry Pi how to read analog inputs is easier than you think! The Pi does not include a hardware analog to digital converter, but a external ADC (such as the MCP3008 (http://adafru.it/856)) can be used along with some bit banged SPI code in python to read external analog devies. Here is a short list of some analog inputs that could be used with this setup. potentiometer (http://adafru.it/356) photocell (http://adafru.it/161) force sensitive resistor ( FSR ) (http://adafru.it/166) temperature sensor (http://adafru.it/165) 2-axis joystick (http://adafru.it/512) This guide uses a potentiometer to control the volume of a mp3 file being played, but the code can be used as the basis for any kind of analog-input project
© Adafruit Industries
http://learn.adafruit.com/reading-a-analog-in-and-controlling-audiovolume-with-the-raspberry-pi
Page 3 of 12
Connecting the Cobbler to a MCP3008 To follow this tutorial you will need
MCP3008 DIP-package ADC converter chip (http://adafru.it/856) 10K trimer (http://adafru.it/356) or panel mount potentiometer (http://adafru.it/562) Adafruit Pi Cobbler (http://adafru.it/914) - follow the tutorial to assemble it Half (http://adafru.it/64) or Full-size breadboard (http://adafru.it/239) Breadboarding wires (http://adafru.it/aHz) And of course a working Raspberry Pi with Internet connection
Why we need an ADC
The Raspberry Pi computer does not have a way to read analog inputs. It's a digital-only computer. Compare this to the Arduino, AVR or PIC microcontrollers that often have