print("Hello, Pi Pico W!")
from picozero import RGBLED, Button
import time
colors = ['red', 'green', 'blue', 'purple', 'cyan', 'yellow', 'white'] #This list indicates all the colors that the led will be. # The colors in words, corresponds with colorsdefined. These two things are in direct corolation this line states the colors and colorsdefined, defines its rgb code.
button = Button(3)
colorsindex = 0
RGB = RGBLED(red = 0, green = 1, blue = 2)
colorsdefined = {
'red': (255, 0, 0),
'green': (0, 255, 0),
'blue': (0, 0, 255),
'purple': (255, 0, 255),
'cyan': (0, 255, 255),
'yellow': (255, 255, 0),
'white': (255, 255, 255)
}
while True:
rgbs = colorsdefined[colors[colorsindex]]
RGB.color = rgbs
print(colors[colorsindex])
colorsindex = (colorsindex + 1) % len(colors)
time.sleep(0.2)
if button.is_pressed: #Detects if the button is pressed and turns off the RGB if the condition is met. The while true statement is so that if the button is pressed after the RGBLED is turned on it will hold the LED in a loop.
RGB.off
while True:
time.sleep(0.2)
Loading
pi-pico-w
pi-pico-w