Sie sind auf Seite 1von 6

Connecting the Cobbler to a MCP3008 | Analog Inputs fo...

http://learn.adafruit.com/reading-a-analog-in-and-control...

Overview Connecting the Cobbler to a MCP3008 Necessary Packages Python Script Run It Download PDF

Search the Adafruit Learning System


Home/ Raspberry Pi/ Analog Inputs for Raspberry Pi Using the MCP3008/ Connecting the Cobbler to a MCP3008 Featured in this Guide

Analog Inputs for Raspberry Pi Using the Full sized breadboard MCP3008
Convert analog inputs to digital and control audio volume Overview Connecting the Cobbler to a MCP3008 Necessary Packages Python Script Run Itto Cart $7.95 Add Half-size breadboard Single Page Download PDF Feedback? Corrections?

$5.00 Add to Cart Panel Mount 10K potentiometer (Breadboard Friendly)

$0.95 Add to Cart Breadboard trim potentiometer

1 of 6

16/10/13 20:38

Connecting the Cobbler to a MCP3008 | Analog Inputs fo...

http://learn.adafruit.com/reading-a-analog-in-and-control...

$1.25 Add to Cart GPIO Ribbon Cable for Raspberry Pi

$2.95 Add to Cart Adafruit Pi Box - Enclosure for Raspberry Pi Model A or B

$14.95 Add to Cart Adafruit Assembled Pi Cobbler Breakout + Cable for Raspberry Pi

$7.95 Add to Cart Add all to Cart


Out of Stock Notication

Your Name: Notify Me

Your E-mail:

Connecting the Cobbler to a MCP3008 Created by Mikey Sklar


2 of 6 16/10/13 20:38

Connecting the Cobbler to a MCP3008 | Analog Inputs fo...

http://learn.adafruit.com/reading-a-analog-in-and-control...

To follow this tutorial you will need


MCP3008 DIP-package ADC converter chip 10K trimer or panel mount potentiometer Adafruit Pi Cobbler - follow the tutorial to assemble it Half or Full-size breadboard Breadboarding wires 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 6 or more analog inputs! Analog inputs are handy because many sensors are analog outputs, so we need a way to make the Pi analog-friendly. We'll do that by wiring up an MCP3008 chip to it. The MCP3008 acts like a 'bridge' between digital and analog. It has 8 analog inputs and the Pi can query it using 4 digital pins. That makes it a perfect addition to the Pi for integrating simple sensors like photocells, FSRs or potentiometers, thermistors, etc.! Lets check the datasheet of the MCP3008 chip. On the rst page in the lower right corner there's a pinout diagram showing the names of the pins

Wiring Diagram
In order to read analog data we need to use the following pins: VDD (power), DGND (digital ground) to power the MCP3008 chip. We also need four 'SPI' data pins: DOUT (Data Out from MCP3008), CLK (Clock pin), DIN (Data In from Raspberry Pi), and /CS (Chip Select). Finally of course, a source of analog data, we'll be using the basic 10k trim pot.

3 of 6

16/10/13 20:38

Connecting the Cobbler to a MCP3008 | Analog Inputs fo...

http://learn.adafruit.com/reading-a-analog-in-and-control...

The MCP3008 has a few more pins we need to connect: AGND (analog ground, used sometimes in precision circuitry, which this is not) connects to GND, and VREF (analog voltage reference, used for changing the 'scale' - we want the full scale so tie it to 3.3V) Below is a wiring diagram. Connect the 3.3V cobbler pin to the left + rail and the GND pin to the right - rail. Connect the following pins for the MCP chip MCP3008 MCP3008 MCP3008 MCP3008 MCP3008 MCP3008 MCP3008 MCP3008 VDD -> 3.3V (red) VREF -> 3.3V (red) AGND -> GND (black) CLK -> #18 (orange) DOUT -> #23 (yellow) DIN -> #24 (blue) CS -> #25 (violet) DGND -> GND (black)

Next connect up the potentiometer. Pin #1 (left) goes to GND (black), #2 (middle) connects to MCP3008 CH0 (analog input #0) with a gray wire, and #3 (right) connects to 3.3V (red) Advanced users may note that the Raspberry Pi does have a hardware SPI interface (the cobbler pins are labeled MISO/MOSI/SCLK/CE0/CE1). The hardware SPI interface is super fast but not included in all distributions. For that reason we are using a bit banged SPI implementation so the SPI pins can be any of the raspberry pi's GPIOs (assuming you update the script).

< Overview Necessary Packages >

4 of 6

16/10/13 20:38

Connecting the Cobbler to a MCP3008 | Analog Inputs fo...

http://learn.adafruit.com/reading-a-analog-in-and-control...

Last updated on 2012-07-20 at 08.33.52 PM

Related Guides

Arduino Lesson 15. DC Motor Reversing Learn Arduino, Lesson 15. DC Motor Reversing

Arduino Lesson 14. Servo Motors Learn Arduino, Lesson 14. Servo Motors

5 of 6

16/10/13 20:38

Connecting the Cobbler to a MCP3008 | Analog Inputs fo...

http://learn.adafruit.com/reading-a-analog-in-and-control...

Adafruit Pi Cobbler Kit Assemble your Adafruit Pi Cobbler Kit About Adafruit Adafruit was founded in 2005 by MIT engineer, Limor "Ladyada" Fried. Her goal was to create the best place online for learning electronics and making the best designed products for makers of all ages and skill levels. Learn More. The Adafruit Learning System In 2012, after years of coding tutorials by hand, Limor put together a small team to build a custom tutorial management system from the ground up. The Adafruit Learning System allows us to make a wide range of awesome tutorials fast and eciently. We hope these tutorials will help you learn something new, and inspire you to make something great! Useful Stu Support Forums Adafruit Shop RSS 340 tutorials and counting Powered by Adafruit Learning Technologies

6 of 6

16/10/13 20:38

Das könnte Ihnen auch gefallen