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