# SPDX-FileCopyrightText: 2021 Jeff Epler, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
#
# Adapted from the example https://github.com/raspberrypi/pico-examples/tree/master/pio/hello_pio

import time
import board
import rp2pio
import adafruit_pioasm
 
hello = """
.program hello
.side_set 2
.wrap_target
    set x 10 side 0
waitloop:
    jmp x-- waitloop side 1 [7]

    set x 10 side 0
waitloop:
    jmp x-- waitloop side 2 [7]
.wrap

"""

assembled = adafruit_pioasm.assemble(hello)

sm = rp2pio.StateMachine(
    assembled,
    frequency=2000,
    first_sideset_pin=board.GP15,
    sideset_pin_count=1
)

print("real frequency", sm.frequency)

while True:
    #sm.write(bytes((1,)))
    time.sleep(0.5)
    #sm.write(bytes((0,)))
    #time.sleep(0.5)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT