Created
February 12, 2018 09:56
-
-
Save pierre-rouanet/a1ea447c3b6a6c0992331f03f708b18b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyluos import Robot | |
robot = Robot('/dev/cu.usbserial-14310') | |
button = robot.btn_gpios.p8 | |
potentiometer = robot.btn_gpios.p9 | |
blue_led = robot.led_gpios.p2 | |
green_led = robot.led_gpios.p3 | |
red_led = robot.led_gpios.p4 | |
def turn_on(selected_led): | |
for led in (blue_led, green_led, red_led): | |
if led == selected_led: | |
led.set_high() | |
else: | |
led.set_low() | |
threshold = 4096 / 3 | |
while True: | |
if potentiometer.read() < threshold: | |
turn_on(blue_led) | |
elif potentiometer.read() < 2 * threshold: | |
turn_on(green_led) | |
else: | |
turn_on(red_led) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment