Created
February 8, 2025 17:55
-
-
Save Lilahzr/0c06b9dc86a3248302d2757d58fdd849 to your computer and use it in GitHub Desktop.
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
import time | |
import board | |
import neopixel | |
from digitalio import DigitalInOut, Direction, Pull | |
pixel_pin = board.D2 | |
num_pixels = 16 | |
switch = DigitalInOut(board.D3) | |
switch.direction = Direction.INPUT | |
switch.pull = Pull.UP | |
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False) | |
RED = (255, 50, 0) | |
YELLOW= (255, 111, 0) | |
OFF = (0, 0, 0) | |
while True: | |
print(switch.value) | |
if (switch.value == True): | |
pixels.fill(RED) | |
pixels.show() | |
time.sleep(3) | |
pixels.fill(YELLOW) | |
pixels.show() | |
time.sleep(3) | |
# debounce delay | |
else: | |
pixels.fill(OFF) | |
pixels.show() | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment