Have you ever wanted to get the timing of the color of an RGB LED to sync with your piezo notes? If so, this is the Instructable for you! This project was designed by Rachelle Tan and Emily Brooks as part of the Physical Computing and Fabrication course at the Digital Humanities Summer Institute 2016 at the University of Victoria. The elements included were an origami heart box that opened to reveal a big red button that when pressed started a rainbow LED display that syncs with the first stanza of "What the World Needs Now" by Hal David and Burt Bacharach. I have included our Arduino files and a diagram to help you replicate the project. I would love to see how you use and modify this tutorial!

## Step 1: Parts Needed

For this project you will need:

(1) Arduino Uno

(1) USB cable

(1) RGB LED

(1) Piezo

(4) Resistors

(10) Jumper cables

(1) Big Red Button (not pictured)

(2) Alligator clips (not pictured)

## Step 2: Start Arduino Sketch

To start you new sketch:

1. Open Arduino
2. Go to File > New
3. Go to File > Save and name your sketch folder
4. Declare your variables as int (integers)
5. Make arrays[] for melody, note durations, and the red, green, and blue values
6. In void setup(), set your pinMode for the RGB pins as OUTPUT and for the button as INPUT
7. In void loop(), use digitalRead to read the value of whether the button has been pressed or not to determine if the tone should be played

(Links are connected to Arduino Reference pages)

## Step 3: Include Pitches Library

To include the pitches.h library:

1. Write #include "pitches.h" at the top of your code
2. Click the down arrow to the right on the IDE> click New Tab
3. Name the new file pitches.h
4. Copy and paste the values in pitches.h
5. Save file

## Step 4: Finish Code

In order to finish the code:

1. Determine what colors and order you want for your array. Make arrays for R, G, and B values on scales of 0-255 (Red = 255,0,0; Orange = 255,165,0; Yellow= 255,255,0; Green= 0,255,0; Teal= 0,255,255; Blue= 0,0,255; Violet= 255,0,255)
2. Read your sheet music and translate into usable data (C4=middle of piano/treble clef, 4=quarter note)
3. Write a function to analogWrite values to each pin of the RGB LED

Find finished code attached to this tutorial.

## Step 5: Assemble Prototype

2. Carefully plug the leads of the piezo, RGB LED, and button into the breadboard as shown in the diagram (we used alligator clips to connect the button)
3. Plug in the resistors of the RGB LED pins
4. Use jumper cables to connect the parts to the Arduino pins based on the pin numbers you declared in your code

## Step 6: Run Code and Enjoy!

To complete the project:

2. Verify your code by hitting the checkmark in the top left hand corner
3. Go to Tools > Board and select Arduino Uno
4. Go to Tools > Serial Port and ensure that your laptop is recognizing that you have connected your Arduino
5. Click the right arrow (Upload) and enjoy the efforts of all of your hard work!
<p>Arduino: 1.6.10 (Mac OS X), Board: &quot;Arduino/Genuino Uno&quot;<br><br>/Users/----/Downloads/RGB_Piezo/RGB_Piezo.ino:10:21: fatal error: pitches.h: No such file or directory<br> #include &quot;pitches.h&quot;<br> ^<br>compilation terminated.<br>exit status 1<br>Error compiling for board Arduino/Genuino Uno.<br><br>This report would have more information with<br>&quot;Show verbose output during compilation&quot;<br>option enabled in File -&gt; Preferences.</p><p>why am i getting this when i try to upload even though pitches.h file is there and open</p>
<p>Hi @scratchndent, it looks to me like you're opening a file from the Downloads folder and need to move it to your Arduino sketch folders. Check out this site for more info: https://programmingelectronics.com/understanding-the-arduino-sketchbook-opening-and-saving-arduino-sketches/</p>
<p>very nice ))))))))</p>