mcp3xxx_mcp3004_differential_simpletest.py
1 import busio 2 import digitalio 3 import board 4 import adafruit_mcp3xxx.mcp3004 as MCP 5 from adafruit_mcp3xxx.analog_in import AnalogIn 6 7 # create the spi bus 8 spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) 9 10 # create the cs (chip select) 11 cs = digitalio.DigitalInOut(board.D5) 12 13 # create the mcp object 14 mcp = MCP.MCP3004(spi, cs) 15 16 # create a differential ADC channel between Pin 0 and Pin 1 17 chan = AnalogIn(mcp, MCP.P0, MCP.P1) 18 19 print("Differential ADC Value: ", chan.value) 20 print("Differential ADC Voltage: " + str(chan.voltage) + "V")