Skip to content

Instantly share code, notes, and snippets.

@petebachant
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save petebachant/114c8088660ea8e2f238 to your computer and use it in GitHub Desktop.

Select an option

Save petebachant/114c8088660ea8e2f238 to your computer and use it in GitHub Desktop.
Toggle a BeagleBone digital output.
#!/usr/bin/env python
from Adafruit_BBIO import GPIO
pin = "P8_13"
exit = False
state = 1
GPIO.setup(pin, GPIO.OUT)
while not exit:
exit = (raw_input("Press any key to toggle output, or 'exit()' to exit >> ") == "exit()")
if state == 1:
GPIO.output(pin, GPIO.HIGH)
else:
GPIO.output(pin, GPIO.LOW)
state *= -1
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment