/ examples / bbb_digitalio.py
bbb_digitalio.py
 1  #!/usr/bin/env python3
 2  # -*- coding: utf-8 -*-
 3  
 4  # Example of blinking LED on BeagleBone Black
 5  # https://www.adafruit.com/product/1876
 6  #
 7  # Wire the circuit as follows:
 8  # 1) connect anode (+) lead of LED to P9.12 pin
 9  # 2) connect cathode (-) lead to 1K Ohm resistor
10  # 3) connect that 1K Ohm resistor to DGND (P9.1)
11  #
12  # NOTE: the pin mode can be verified with the command line
13  # utility config-pin on the BeagleBoard.org Debian image
14  #
15  # To verify the pin is in GPIO mode:
16  # debian@beaglebone:~$ config-pin -q p9.12
17  # P9_12 Mode: gpio Direction: out Value: 0
18  #
19  # To set pin to GPIO mode:
20  # $ config-pin p9.12 gpio
21  
22  import time
23  import board
24  import digitalio
25  
26  print("hello blinky!")
27  
28  led = digitalio.DigitalInOut(board.P9_12)
29  led.direction = digitalio.Direction.OUTPUT
30  
31  while True:
32      led.value = True
33      time.sleep(0.5)
34      led.value = False
35      time.sleep(0.5)