Skip to content

Instantly share code, notes, and snippets.

@dmalawey
Created November 19, 2019 22:21
Show Gist options
  • Save dmalawey/5a38554d3fff1bab5a7a9699def27334 to your computer and use it in GitHub Desktop.
Save dmalawey/5a38554d3fff1bab5a7a9699def27334 to your computer and use it in GitHub Desktop.
direct copy of button.py on the beaglebone blue image.
#!/usr/bin/env python
# Reads the PAUSE button using interupts and sets the LED
# Pin table at https://github.com/beagleboard/beaglebone-blue/blob/master/BeagleBone_Blue_Pin_Table.csv
# Import PyBBIO library:
import Adafruit_BBIO.GPIO as GPIO
import time
button="P8_9" # PAUSE=P8_9, MODE=P8_10
LED ="USR3"
# Set the GPIO pins:
GPIO.setup(LED, GPIO.OUT)
GPIO.setup(button, GPIO.IN)
print("Running...")
while True:
state = GPIO.input(button)
GPIO.output(LED, state)
GPIO.wait_for_edge(button, GPIO.BOTH)
print("Pressed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment