Adapt first example from the Micropython book
This commit is contained in:
parent
3a64ca716b
commit
72c2324ff5
1 changed files with 40 additions and 0 deletions
40
examples/getting-started/led_brightness.py
Normal file
40
examples/getting-started/led_brightness.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# SPDX-FileCopyrightText: 2021 Jeff Epler, written for Adafruit Industries
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
# Adapted from the an example in Appendix C of file:///tmp/mozilla_jepler0/RPi_PiPico_Digital_v10.pdf
|
||||||
|
|
||||||
|
import adafruit_pioasm
|
||||||
|
import board
|
||||||
|
import rp2pio
|
||||||
|
import time
|
||||||
|
|
||||||
|
led_quarter_brightness = adafruit_pioasm.assemble("""
|
||||||
|
set pins, 0 [2]
|
||||||
|
set pins, 1
|
||||||
|
""")
|
||||||
|
|
||||||
|
led_half_brightness = adafruit_pioasm.assemble("""
|
||||||
|
set pins, 0
|
||||||
|
set pins, 1
|
||||||
|
""")
|
||||||
|
|
||||||
|
led_full_brightness = adafruit_pioasm.assemble("""
|
||||||
|
set pins, 1
|
||||||
|
""")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
sm = rp2pio.StateMachine(led_quarter_brightness,
|
||||||
|
frequency=10000, first_set_pin=board.LED)
|
||||||
|
time.sleep(1)
|
||||||
|
sm.deinit()
|
||||||
|
|
||||||
|
sm = rp2pio.StateMachine(led_half_brightness,
|
||||||
|
frequency=10000, first_set_pin=board.LED)
|
||||||
|
time.sleep(1)
|
||||||
|
sm.deinit()
|
||||||
|
|
||||||
|
sm = rp2pio.StateMachine(led_full_brightness,
|
||||||
|
frequency=10000, first_set_pin=board.LED)
|
||||||
|
time.sleep(1)
|
||||||
|
sm.deinit()
|
||||||
Loading…
Reference in a new issue