MCP3008 Setup
Connections
MCP3008 Pin | Rasp Pi Signal | |
---|
VDD | +3.3V | | VREF | +3.3V | | AGND | GND | | CLK | SCLK | | DOUT | MISO | | DIN | MOSI | | CS /SHDN | CE0 | | DGND | GND | |
| 
| |
CH<number> pins get connected to the AnalogOUT of the analog circuits
Analog Circuits
Force-sensitive Resistor

Photocell

Potentiometer (Variable Resistor)

Running SPI Sample
First build the dio-spi.jar file: Then copy ../../build/jar/dio-spi.jar to the board. | (On the Pi) For this example you should have SPIDevice entry in your dio.properties file like this example for the raspberry pi: 12 = deviceType: spibus.SPIDevice, name:SPI_Slave, deviceNumber: 0 , address: 0 , csActive: 1 , wordLength: 8 , clockFrequency: 500000 , clockMode: 1 , bitOrdering: 1
|
Note that these are the current values in the repo which reflect a recent update. Older dio.peprties versions will not work. sudo $JAVA_HOME/bin/java -Djava.library.path=. -Djava.security.policy=./java.policy -classpath .:./dio.jar:dio-samples.jar:dio-spi.jar -Djdk.dio.registry=./dio.properties -Ddeviceaccess.uart.prefix=/dev/ttyAMA dio.spi.MCP3008Sample 12 4 |
Note that "12" is the device manager ID number of the SPIDevice in the example property line shown above. "4" selects the channel on the MPC3008. You should use the channel number connected to the analog circuit you're trying to read. |