Created
September 6, 2020 00:41
-
-
Save rowena-s/fd8a92d04f97508cd084568a1d332000 to your computer and use it in GitHub Desktop.
Curlyboi code using play_tone instead of sample files
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
from adafruit_circuitplayground.express import cp | |
from time import sleep | |
#define your things because magic numbers are bad | |
G3 = 196 | |
A3 = 200 | |
C4 = 262 | |
D4 = 294 | |
E4 = 330 | |
G4 = 392 | |
A4 = 440 | |
C5 = 523 | |
beat = 0.1 | |
cp.pixels.brightness = 0.1 | |
ctr = 0 | |
while True: | |
if cp.touch_A1: | |
ctr = 0 | |
cp.pixels.fill((0,100,0)) | |
if cp.button_a: | |
cp.play_tone(C5, beat) | |
else: | |
cp.play_tone(C4, beat) | |
elif cp.touch_A2: | |
ctr = 0 | |
cp.pixels.fill((255,100,0)) | |
cp.play_tone(D4, beat) | |
elif cp.touch_A3: | |
ctr = 0 | |
cp.pixels.fill((255,215,0)) | |
cp.play_tone(E4, beat) | |
elif cp.touch_A4: | |
ctr = 0 | |
cp.pixels.fill((255, 0, 0)) | |
if cp.button_a: | |
cp.play_tone(G3, beat) | |
else: | |
cp.play_tone(G4, beat) | |
elif cp.touch_A5: | |
ctr = 0 | |
cp.pixels.fill((75,0,130)) | |
if cp.button_a: | |
cp.play_tone(A3, beat) | |
else: | |
cp.play_tone(A4, beat) | |
if ctr == 4: | |
cp.pixels.fill((0,0,0)) | |
ctr += 1 | |
sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment