From: Drew Fustini Date: Sun, 31 Mar 2019 23:20:45 +0000 (+0100) Subject: add PocketBeagle example to blink LED X-Git-Tag: 1.3.0~5 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/6eaaf3282e5177bd0fd4113c6d5d7fc02f102c69?ds=inline add PocketBeagle example to blink LED add PocketBeagle example to blink LED Note: Python programs using Blinka on PocketBeagle and BeagleBone need to use `sudo`. Refer to this issue for more information: https://github.com/adafruit/Adafruit_Python_PlatformDetect/issues/20 Here is the output of this program running OK on a PocketBeagle: debian@beaglebone:~/Adafruit_Blinka/examples$ sudo python3 pb_digitalio.py [sudo] password for debian: hello blinky! --- diff --git a/examples/pb_digitalio.py b/examples/pb_digitalio.py new file mode 100644 index 0000000..efa9cff --- /dev/null +++ b/examples/pb_digitalio.py @@ -0,0 +1,32 @@ +# Example of blinking LED on PocketBeagle +# https://www.adafruit.com/product/4179 +# +# Wire the circuit as follows: +# 1) connect anode (+) lead of LED to P1_33 pin +# 2) connect cathode (-) lead to 1K Ohm resistor +# 3) connect that 1K Ohm resistor to GND +# +# NOTE: the pin mode can be verified with the command line +# utility config-pin on the BeagleBoard.org Debian image +# +# To verify the pin is in GPIO mode: +# debian@beaglebone:~$ config-pin -q p1.33 +# P1_33 Mode: gpio Direction: out Value: 0 +# +# To set pin to GPIO mode: +# $ config-pin p1.33 gpio + +import time +import board +import digitalio + +print("hello blinky!") + +led = digitalio.DigitalInOut(board.P1_33) +led.direction = digitalio.Direction.OUTPUT + +while True: + led.value = True + time.sleep(0.5) + led.value = False + time.sleep(0.5)