From 6eaaf3282e5177bd0fd4113c6d5d7fc02f102c69 Mon Sep 17 00:00:00 2001 From: Drew Fustini Date: Mon, 1 Apr 2019 00:20:45 +0100 Subject: [PATCH] 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! --- examples/pb_digitalio.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/pb_digitalio.py 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) -- 2.49.0