summaryrefslogtreecommitdiff
path: root/Adafruit_Python_MCP3008/examples
diff options
context:
space:
mode:
authorCody Hiar <codyfh@gmail.com>2018-05-27 15:29:21 -0600
committerCody Hiar <codyfh@gmail.com>2018-05-27 15:29:21 -0600
commitceec171c42bd79f1762b971569e20ead656f4fd0 (patch)
tree1880be0b1cef9786be5bc818cbd50095cd797a6d /Adafruit_Python_MCP3008/examples
parent611a8b7be4331e4f8416c4d10a0be47a109b47e4 (diff)
Moving libs into separate own directory
Diffstat (limited to 'Adafruit_Python_MCP3008/examples')
-rw-r--r--Adafruit_Python_MCP3008/examples/differential.py38
-rw-r--r--Adafruit_Python_MCP3008/examples/simpletest.py39
2 files changed, 0 insertions, 77 deletions
diff --git a/Adafruit_Python_MCP3008/examples/differential.py b/Adafruit_Python_MCP3008/examples/differential.py
deleted file mode 100644
index df30e65..0000000
--- a/Adafruit_Python_MCP3008/examples/differential.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Simple example of reading the MCP3008 analog input channels using its
-# differential mode. Will print the difference of channel 0 and 1.
-# Author: Tony DiCola
-# License: Public Domain
-import time
-
-# Import SPI library (for hardware SPI) and MCP3008 library.
-import Adafruit_GPIO.SPI as SPI
-import Adafruit_MCP3008
-
-
-# Software SPI configuration:
-# CLK = 18
-# MISO = 23
-# MOSI = 24
-# CS = 25
-# mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI)
-
-# Hardware SPI configuration:
-SPI_PORT = 0
-SPI_DEVICE = 0
-mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
-
-print('Press Ctrl-C to quit...')
-while True:
- # Grab the difference between channel 0 and 1 (i.e. channel 0 minus 1).
- # Note you can specify any value in 0-7 to grab other differences:
- # - 0: Return channel 0 minus channel 1
- # - 1: Return channel 1 minus channel 0
- # - 2: Return channel 2 minus channel 3
- # - 3: Return channel 3 minus channel 2
- # - 4: Return channel 4 minus channel 5
- # - 5: Return channel 5 minus channel 4
- # - 6: Return channel 6 minus channel 7
- # - 7: Return channel 7 minus channel 6
- value = mcp.read_adc_difference(0)
- print('Channel 0 minus 1: {0}'.format(value))
- time.sleep(0.5)
diff --git a/Adafruit_Python_MCP3008/examples/simpletest.py b/Adafruit_Python_MCP3008/examples/simpletest.py
deleted file mode 100644
index 23f9f0c..0000000
--- a/Adafruit_Python_MCP3008/examples/simpletest.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Simple example of reading the MCP3008 analog input channels and printing
-# them all out.
-# Author: Tony DiCola
-# License: Public Domain
-import time
-
-# Import SPI library (for hardware SPI) and MCP3008 library.
-import Adafruit_GPIO.SPI as SPI
-import Adafruit_MCP3008
-
-
-# Software SPI configuration:
-CLK = 18
-MISO = 23
-MOSI = 24
-CS = 25
-mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI)
-
-# Hardware SPI configuration:
-# SPI_PORT = 0
-# SPI_DEVICE = 0
-# mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))
-
-
-print('Reading MCP3008 values, press Ctrl-C to quit...')
-# Print nice channel column headers.
-print('| {0:>4} | {1:>4} | {2:>4} | {3:>4} | {4:>4} | {5:>4} | {6:>4} | {7:>4} |'.format(*range(8)))
-print('-' * 57)
-# Main program loop.
-while True:
- # Read all the ADC channel values in a list.
- values = [0]*8
- for i in range(8):
- # The read_adc function will get the value of the specified channel (0-7).
- values[i] = mcp.read_adc(i)
- # Print the ADC values.
- print('| {0:>4} | {1:>4} | {2:>4} | {3:>4} | {4:>4} | {5:>4} | {6:>4} | {7:>4} |'.format(*values))
- # Pause for half a second.
- time.sleep(0.5)