Talking Painting of RBG

For this project I copied audio from some of RBG’s public speeches and then modified the audio files in Audacity to fit onto the CPX.  The CircuitPython program triggers the audio files to play when the pad is touched.

 

RBG YouTube Video

 

Here is the CircuitPython Code:

import board
import audioio
import time
import random
from adafruit_circuitplayground.express import cpx

cpx.adjust_touch_threshold(500)

wave_file = open(“rbg.wav”, “rb”)
wave = audioio.WaveFile(wave_file)
audio = audioio.AudioOut(board.A0)

wave_file1 = open(“rbg1.wav”, “rb”)
wave1 = audioio.WaveFile(wave_file1)

wave_file2 = open(“rbg2.wav”, “rb”)
wave2 = audioio.WaveFile(wave_file2)

myWaveList = [wave, wave1, wave2]
i = 0

while True:
if cpx.touch_A3:
i = (i + 1)
three = [.1, .2, .3]
four = [.1, .2, .3, .4, .5]
five = [.2, .4, .5]
rest = 0.3 * random.random()
rest1 = 0.3 * random.random()
rest2 = 0.3 * random.random()
print(“button A5 was pressed”, (i))
audio.play(myWaveList[i % 3])
while audio.playing:
cpx.pixels[2] = (150, 0, 0)
time.sleep(rest)
cpx.pixels[3] = (150, 0, 0)
time.sleep(rest1)
cpx.pixels[2] = (0, 0, 0)
cpx.pixels[3] = (0, 0, 0)
time.sleep(rest2)

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s