# Import the Pin class from the machine module. # This allows us to control the RP2040's GPIO (General Purpose Input/Output) pins. from machine import Pin # Import the neopixel module. # This provides functions for controlling WS2812 (NeoPixel) RGB LEDs. import neopixel # Import the time module. # We'll use this to create delays with sleep(). import time # The GPIO pin connected to the data input of the WS2812 LED. # On many Waveshare RP2040 boards this is GPIO 16. LED_PIN = 16 # Create a NeoPixel object. # # Pin(LED_PIN) tells MicroPython which GPIO pin is connected # to the LED. The GPIO pin number is set by previous variable LED_PIN=16 # # The second parameter (1) tells it there is only ONE RGB LED # connected to this pin. np = neopixel.NeoPixel(Pin(LED_PIN), 1) # Start an infinite loop. # Everything inside this loop will repeat forever. while True: # Set LED number 0 (the first and only LED) # to the colour Red. # # Colours are stored as: # (Red, Green, Blue) # # Each value can range from: # 0 = Off # 255 = Maximum brightness # # So this means: # Red = 255 (full brightness) # Green = 0 # Blue = 0 np[0] = (8, 0, 8) # I changed the colour from bright Red to a soft Purple. # Send the colour data to the LED. # # Changing np[0] only changes the value in memory. # The LED won't actually change until write() is called. np.write() # Wait for half a second. time.sleep(0.5) # Set the LED colour to black (off). # # Since all three colours are zero, # the LED turns off. np[0] = (0, 0, 0) # Update the LED so it turns off. np.write() # Wait another half second before repeating. time.sleep(0.5) #other colours #(255, 0, 0), # Red #(0, 255, 0), # Green #(0, 0, 255), # Blue #(255, 255, 0), # Yellow #(255, 0, 255), # Magenta #(0, 255, 255), # Cyan #(255, 255, 255),# White #(0, 0, 0) # Off