]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
add PocketBeagle example to blink LED
authorDrew Fustini <drew@pdp7.com>
Sun, 31 Mar 2019 23:20:45 +0000 (00:20 +0100)
committerGitHub <noreply@github.com>
Sun, 31 Mar 2019 23:20:45 +0000 (00:20 +0100)
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 [new file with mode: 0644]

diff --git a/examples/pb_digitalio.py b/examples/pb_digitalio.py
new file mode 100644 (file)
index 0000000..efa9cff
--- /dev/null
@@ -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)