Created
October 18, 2022 22:03
-
-
Save dglaude/e6c50876e199cc31db1fe00bd8636378 to your computer and use it in GitHub Desktop.
Seeeduino XIAO RP2040: Build in RGB LED simultaniously as NeoPixel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Seeeduino XIAO RP2040: Build in RGB LED simultaniously as NeoPixel.""" | |
import time | |
import board | |
import neopixel | |
import digitalio | |
BLACK = (0, 0, 0) | |
RED = (255, 0, 0) | |
GREEN = (0, 255, 0) | |
BLUE = (0, 0, 255) | |
WHITE = (255, 255, 255) | |
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1) | |
pixel.brightness = 0.3 | |
led_blue = digitalio.DigitalInOut(board.LED_BLUE) | |
led_blue.direction = digitalio.Direction.OUTPUT | |
led_green = digitalio.DigitalInOut(board.LED_GREEN) | |
led_green.direction = digitalio.Direction.OUTPUT | |
led_red = digitalio.DigitalInOut(board.LED_RED) | |
led_red.direction = digitalio.Direction.OUTPUT | |
led_red.value = False | |
led_blue.value = False | |
led_green.value = False | |
pixel.fill(WHITE) | |
time.sleep(1) | |
led_red.value = True | |
led_blue.value = True | |
led_green.value = True | |
pixel.fill(BLACK) | |
time.sleep(4) | |
while True: | |
led_red.value = True | |
led_blue.value = True | |
led_green.value = True | |
led_red.value = False | |
pixel.fill(RED) | |
time.sleep(0.5) | |
led_red.value = True | |
led_blue.value = True | |
led_green.value = True | |
led_green.value = False | |
pixel.fill(GREEN) | |
time.sleep(0.5) | |
led_red.value = True | |
led_blue.value = True | |
led_green.value = True | |
led_blue.value = False | |
pixel.fill(BLUE) | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment