def main(): import sys import RPi gpio = IO(RPi.GPIO) mcp = Mcp3008(gpio) gpio.start() mcp.start() value = mcp.read(int(sys.argv[1])) print("value: {}".format(value)) gpio.stop()
def main(): interval = None if len(sys.argv) > 1: interval = float(sys.argv[1]) from RPi import GPIO from justaled.mcp3008 import Mcp3008 from justaled.io import IO from time import sleep io = IO(GPIO) mcp = Mcp3008(io, reference_voltage=3.3) io.start() mcp.start() publish(sample(mcp)) while interval: publish(sample(mcp)) sleep(interval)