Categories
Classes Projects

Make a Color-Changing Silhouette Light

Touch pad input (capacitive touch)

import board
import neopixel
from time import sleep
import random
from adafruit_circuitplayground import cp



RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
PURPLE = (128, 0, 128)

NUM_LEDS = 10
PIXEL_PIN = board.D8

#np = neopixel.NeoPixel(PIXEL_PIN, NUM_LEDS, brightness=0.1, auto_write=False)
np = cp.pixels
np.brightness = 0.1

def ColorShow():
for i in range(NUM_LEDS):
red = random.randint(0, 255)
green = random.randint(0, 255)
blue = random.randint(0, 255)
new_color = (red, green, blue)
np[i] = new_color
np.show()
return new_color


def ColorWheel(new_color):
for i in range(NUM_LEDS):
np[i] = new_color
np.show()
sleep(0.2)


while True:
if cp.touch_A3:
print("Touched!")
cp.play_tone(440,1)

print("Displaying ColorShow")
next = ColorShow()
sleep(0.5)

print("Displaying ColorWheel", next)
ColorWheel(next)
sleep(0.5)