Skip to content

Commit 1765438

Browse files
author
brentru
committed
analog_in example match new MCP3xxx API
1 parent 919807d commit 1765438

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: examples/basics/analog_in.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
from Adafruit_IO import Client, Feed, RequestError
2525

2626
# import Adafruit CircuitPython MCP3xxx library
27-
from adafruit_mcp3xxx import adafruit_mcp3xxx
27+
from adafruit_mcp3xxx.mcp3008 import MCP3008
28+
from adafruit_mcp3xxx.analog_in import AnalogIn
2829

2930
# Set to your Adafruit IO key.
3031
# Remember, your key is a secret,
@@ -48,14 +49,15 @@
4849

4950
# create the cs (chip select)
5051
cs = digitalio.DigitalInOut(board.D12)
52+
5153
# create a mcp3008 object
52-
mcp = adafruit_mcp3xxx.MCP3008(spi,cs)
54+
mcp = MCP3008(spi, cs)
5355

5456
# create an an adc (single-ended) on pin 0
55-
adc_single_ended = adafruit_mcp3xxx.AnalogIn(mcp,0)
57+
chan = AnalogIn(mcp, MCP3008.pin_0)
5658

5759
while True:
58-
sensor_data = adc_single_ended.value
60+
sensor_data = chan.value
5961

6062
print('Analog Data -> ', sensor_data)
6163
aio.send(analog.key, sensor_data)

0 commit comments

Comments
 (0)