Below are a few examples of using the Adafruit_BBIO.GPIO module. It's fairly simple to use.
You may need to run this library with sudo, particularly on Ubuntu.
Setup
To setup a digital pin as an output, set the output value HIGH, and then cleanup after you're done:
import Adafruit_BBIO.GPIO as GPIO GPIO.setup("P8_10", GPIO.OUT) GPIO.output("P8_10", GPIO.HIGH) GPIO.cleanup()
GPIO.setup("GPIO0_26", GPIO.OUT)
import Adafruit_BBIO.GPIO as GPIO GPIO.setup("P8_14", GPIO.IN)
if GPIO.input("P8_14"): print("HIGH") else: print("LOW")
The wait_for_edge method is blocking, and will wait until something happens:
GPIO.wait_for_edge("P8_14", GPIO.RISING)
A simple example of this is as follows:
GPIO.add_event_detect("P9_12", GPIO.FALLING) #your amazing code here #detect wherever: if GPIO.event_detected("P9_12"): print "event detected!"
Text editor powered by tinymce.