Skip to content

Instantly share code, notes, and snippets.

@RajanRao12
Created May 3, 2022 05:55
Show Gist options
  • Select an option

  • Save RajanRao12/2e04f6db85123113bc2e3ff4202d103d to your computer and use it in GitHub Desktop.

Select an option

Save RajanRao12/2e04f6db85123113bc2e3ff4202d103d to your computer and use it in GitHub Desktop.
import time
import board
import neopixel
from digitalio import DigitalInOut, Direction, Pull
import touchio
touch_pad = board.A0 # the ~1 pin
touch = touchio.TouchIn(touch_pad)
pixel_pin = board.D2
num_pixels = 12
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.3, auto_write=False)
RED = (255, 0, 0) #RGB
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
WHITE = (255,255,255)
OFF = (0,0,0)
ORANGEROBIN = (225,60,20)
REDROBIN = (222,35,5) #yum
colors = [ORANGEROBIN,OFF]
now=0
while True:
if touch.value:
now=now+1
if (now >= len(colors)): #check to see if we exceed our list of colors
now=0
pixels.fill(colors[now])
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