# https://www.instructables.com/Respberry-Pi-Pico-W-NeoPixels-Experiments-With-Pro/ import time import rp2 from machine import Pin @rp2.asm_pio(set_init=rp2.PIO.OUT_LOW, out_shiftdir=rp2.PIO.SHIFT_LEFT) def neo_prog(): pull() # osr <= 24 bits GRB set(x, 23) # x (bit counter) <= 23 label("loop_pixel_bit") out(y, 1) # y <= left-most 1 bit of osr jmp(not_y, "bit_0") set(pins, 1).delay(13) # 1: high (7 cycles) set(pins, 0).delay(9) # 1: low (5 cycles) jmp("bit_end") label("bit_0") set(pins, 1).delay(5) # 0: high (3 cycles) set(pins, 0).delay(17) # 0: low (9 cycles) label("bit_end") jmp(x_dec, "loop_pixel_bit") # x is bit counter sm = rp2.StateMachine(0, neo_prog, freq=20_000_000, set_base=Pin(12)) sm.active(1) g = 0x55 r = 0x0F b = 0x1F grb = (g << 16) + (r << 8) + b while(1): sm.put(grb << 8) time.sleep(0.1)