************************************************ maker-pi-pico-rgb-led_pico.txt ************************************************ # This example uses Maker Pi Pico # Reference: https://www.cytron.io/p-maker-pi-pico # ----- # to stop it completely RESET is useless, unplug from Pi instead import array, time from machine import Pin import rp2 from rp2 import PIO, StateMachine, asm_pio uses functions: ws2812() label() out() side() jmp() nop() StateMachine() active() array() range() print() put() sleep_ms() # Configure the number of WS2812 LEDs # - There's 1x built-in RGB LED on Maker Pi Pico board NUM_LEDS = 1 @asm_pio(sideset_init=PIO.OUT_LOW, out_shiftdir=PIO.SHIFT_LEFT, autopull=True, pull_thresh=24) def ws2812(): T1 = 2 T2 = 5 T3 = 3 label("bitloop") out(x, 1) .side(0) [T3 - 1] jmp(not_x, "do_zero") .side(1) [T1 - 1] jmp("bitloop") .side(1) [T2 - 1] label("do_zero") nop() .side(0) [T2 - 1] # Create the StateMachine with the ws2812 program, outputting on pin GP28 (Maker Pi Pico). sm = StateMachine(0, ws2812, freq=8000000, sideset_base=Pin(28)) # Start the StateMachine, it will wait for data on its FIFO. sm.active(1) # Display a pattern on the LEDs via an array of LED RGB values. ar = array.array("I", [0 for _ in range(NUM_LEDS)]) # maker-pi-pico-rgb-led.py # source: https://github.com/CytronTechnologies/MAKER-PI-PICO/blob/main/Example%20Code/MicroPython/maker-pi-pico-rgb-led.py # date: 2021EMay24 *************************************************************************************** #/maker-pi-pico-rgb-led_pico.txt