import rp2
from machine import Pin
from rp2 import PIO
import time
@rp2.asm_pio(out_init=[PIO.OUT_LOW])
def echo():
wrap_target()
mov(pins, isr)
mov(isr, invert(isr))
pull(noblock)
mov(x, osr)
mov(y, x)
label("loop")
jmp(y_dec, "loop")
wrap()
sm = rp2.StateMachine(0, echo, freq=1_000_000, out_base=Pin(8))
sm.active(1)