See More

#! /usr/bin/env python3 import sys from time import sleep from quick2wire.parts.pcf8591 import * from quick2wire.i2c import I2CMaster address = int(sys.argv[1]) if len(sys.argv) > 1 else BASE_ADDRESS pin_index = int(sys.argv[2]) if len(sys.argv) > 2 else 0 with I2CMaster() as i2c: adc = PCF8591(i2c, FOUR_SINGLE_ENDED) pin = adc.single_ended_input(pin_index) count = 1 while True: print("read: {} : {}".format(count, pin.value)) sleep(0.5) count += 1