commit 1
This commit is contained in:
29
Maker_Pico_Box/rainbow.py
Normal file
29
Maker_Pico_Box/rainbow.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import machine
|
||||
import neopixel
|
||||
import time
|
||||
|
||||
# GP28 pin and number of LEDs
|
||||
pin = 28
|
||||
num_leds = 8 # change to how many LEDs you have
|
||||
|
||||
np = neopixel.NeoPixel(machine.Pin(pin), num_leds)
|
||||
|
||||
# Simple color helper
|
||||
def set_color(r, g, b):
|
||||
for i in range(num_leds):
|
||||
np[i] = (r, g, b)
|
||||
np.write()
|
||||
|
||||
# Demo loop
|
||||
while True:
|
||||
set_color(255, 0, 0) # Red
|
||||
time.sleep(1)
|
||||
|
||||
set_color(0, 255, 0) # Green
|
||||
time.sleep(1)
|
||||
|
||||
set_color(0, 0, 255) # Blue
|
||||
time.sleep(1)
|
||||
|
||||
set_color(0, 0, 0) # Off
|
||||
time.sleep(1)
|
||||
Reference in New Issue
Block a user