import machine
import utime
import rp2
# Blink state machine program. Blinks LED at 10 Hz (with freq=2000)
# 2000 Hz / (20 cycles per instruction * 10 instructions) = 10 Hz
# Single pin (base pin) starts at output and logic low
# Value in brackets is additional delay (max value 31)
@rp2.asm_pio(set_init=rp2.PIO.OUT_LOW)
def toggle():
wrap_target()
set(pins, 1)
set(pins, 0)
wrap()
# Init state machine with "toggle" program
# (state machine 0, running at 125MHz, base pin is GP28)
sm0 = rp2.StateMachine(0, toggle, freq=40_000_000, set_base=machine.Pin(28))
print("Starting state machine...")
sm0.active(1)
utime.sleep(0.01)
sm0.active(0)
print("Stopping state machine...")