Created
May 6, 2026 18:11
-
-
Save 29marimelendezsirota-prog/231d028ef652bcf1b428503e87f78405 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) | |
| PURPLE = (180, 0, 255) | |
| OFF = (0, 0, 0) | |
| while True: | |
| print(switch.value) | |
| if (switch.value == True): | |
| pixels.fill(PURPLE) | |
| pixels.show() | |
| time.sleep(1) # debounce delay | |
| else: | |
| pixels.fill(OFF) | |
| pixels.show() | |
| time.sleep(1) # debounce delay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment