2021-05-13 14:30:18 +00:00
|
|
|
import time
|
2021-05-18 10:18:41 +00:00
|
|
|
from pimoroni_i2c import PimoroniI2C
|
2021-05-13 14:30:18 +00:00
|
|
|
from breakout_ioexpander import BreakoutIOExpander
|
|
|
|
|
2021-05-18 10:18:41 +00:00
|
|
|
PINS_BREAKOUT_GARDEN = {"sda": 4, "scl": 5}
|
|
|
|
PINS_PICO_EXPLORER = {"sda": 20, "scl": 21}
|
|
|
|
|
2021-05-13 14:30:18 +00:00
|
|
|
ioe_adc_pin = 10
|
|
|
|
|
2021-05-18 10:18:41 +00:00
|
|
|
i2c = PimoroniI2C(**PINS_BREAKOUT_GARDEN)
|
|
|
|
ioe = BreakoutIOExpander(i2c, address=0x18)
|
2021-05-13 14:30:18 +00:00
|
|
|
|
|
|
|
ioe.set_mode(ioe_adc_pin, BreakoutIOExpander.PIN_ADC)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
voltage = ioe.input_as_voltage(ioe_adc_pin)
|
|
|
|
print("Voltage: ", voltage, sep="")
|
|
|
|
|
|
|
|
time.sleep(0.02)
|