Skip to content

Instantly share code, notes, and snippets.

@Lilahzr
Created February 8, 2025 17:55
Show Gist options
  • Save Lilahzr/0c06b9dc86a3248302d2757d58fdd849 to your computer and use it in GitHub Desktop.
Save Lilahzr/0c06b9dc86a3248302d2757d58fdd849 to your computer and use it in GitHub Desktop.
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