Skip to content

Instantly share code, notes, and snippets.

@BenjaminSantiago
Created September 22, 2021 06:28
Show Gist options
  • Save BenjaminSantiago/63c89c27f429c01706c32a040c9a0a11 to your computer and use it in GitHub Desktop.
Save BenjaminSantiago/63c89c27f429c01706c32a040c9a0a11 to your computer and use it in GitHub Desktop.
make it so that pressing the button turns the lights off and letting go turns it off.
"""
Here, we'll use the button to light up all the neopixels
"""
# --------------------------
from adafruit_circuitplayground import cp
# --------------------------
# --------------------------
while True:
# light up the neopixels
# if we press button a
if cp.button_a:
cp.pixels.fill((255,255,255))
else:
# if the button is not pressed (else) turn them off
# the fill being "0" is equivalent to "off"
cp.pixels.fill((0, 0, 0))
# --------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment