Lab 5:Build a musical instrument
Part One: Tone Output
Materials:
1) 5 jumper cables
2) Arduino Uno
3) breadboard
4) passive buzzer
5) power cable
6) power source

Step 1) connect jumper cables to 5v and Ground

Step 2) connect 5v and ground to both sides of the breadboard

Step 3) place the passive buzzer in the breadboard and connect the buzzer to ground and digital pin 7.
For part 1, I began by connecting both sides of my breadboard to 5v and ground in the Arduino. I then put the passive buzzer in the breadboard, and connected the positive side (marked with a + ) to digital pin 7, and the other side to ground. Lastly, I programmed my Arduino with the tone() function to produce sound through the buzzer in pin 7 at a frequency of 50 hz. I played with the frequency to produce the most desirable sound.

tone output schematic

testing buzzer output
completed tone output circuit
Part Two: Analog Sensor Input

Step 1) add 2 stacked LDRs to circuit made in part 1
Materials Added to Part 1:
1) 3 more jumper cables
2) 2 Light Dependent Resistors (LDRs)


yellow cable to A0
Step 1) put cable to A0 at the intersection of the LDRs, and connect the sides of the LDRs to 5v and ground
complete analog sensor input circuit
For part 2, I added 2 LDRs to the circuit I made in part 1. I stacked the 2 LDRs so that their legs would intersect in one row, and then I added a cable at this intersection connected the other end to analog pin 0. Then, I used 2 more cables to connect the legs outside of the intersection to 5v and ground in the breadboard. In the code linked above, I made my input A0 (the LDRs) and my output D7 (the buzzer). Then, I programmed the Arduino to map the frequency of the buzzer to the range of the LDRs. Based on the values I was seeing in the serial monitor, I then mapped the LDRs to a range of 200-700. Lastly, I used the tone() function to generate sound through the variable "outPin" (the buzzer) using the variable "output1" (data from the LDRs) as the frequency. I also made the buzzer play for 100 ms with a 1500 ms delay.

analog sensor input schematic
testing analog sensor input circuit
Part Three: Make A Push Button Piano


Step 1) strip down the breadboard to the set up from part 1. Connect 2 cables to digital pins 2 and 3.
Step 2) connect cables from digital pins to one side of each button. connect the other side of the button to 5v. Add 2 10k ohm resistors to the other sides of the buttons and connect to ground to create 2 pull-up resistors.
Materials Added to Part 2:
1) 1 more jumper cable
2) 2 buttons
3) 2 10k resistors

push button piano schematic
testing push button piano

I created by circuit for part 3 by using the starting with the same set up for the passive buzzer from part one. I added 2 buttons connected to 5v, cables connected to digital pins 2 and 3, and 2 10k resistors connected to ground. I then coded the 2 buttons and their respective pins into my program, and used a 3-part if statement to produce different notes when each button is pressed. The code detects if button 1 or 2 is in a HIGH state (when the button is pushed and the circuit is closed), and plays note C2 for button 1, and A2 for button 2. Using the noTone() function, I made the buzzer silent until a button is pushed. I referenced my work for lab 3 for help coding / building the circuit since they were quite similar.
complete push button piano circuit
Part Four: Create Your Own Custom Instrument
Step 1) take out buttons from part 3 and connect cables from digital pins to the breadboard. Connect one cable to 5v, and leave the other end out. place another cable in the same row as the cable connected to the digital pin with one end left out.
Step 2) repeat process 4x to create 4 switches. Add 10k resistors to the same row as the digital pin cable and connect to ground.
new addition(s) to the circuit

Step 6) color coordinate the cables from the DIY switches to their corresponding digital pins
Step 3) add male to female cable extensions
Step 5) separate cables. The 4 cables on the right connect to digital pins, and red cable on the left connects to power
Step 6) add conductive tape to ends of cables
Step 7) tape tabs to fingers of glove in order. tape 5v cable to thumb to supply power to any switch.
complete piano-glove
complete DIY musical instrument circuit
Materials Added to Part 3:
1) 3 more jumper cables
2) 5 male to female cables
3) 2 more 10k resistors
(total of 4)
4) conductive tape
5) glove
I decided to remix my code and circuit from the push-button piano in part 3 to create a DIY piano glove. I replaced the buttons from part 3 with some jumper cables -- putting the cables connected to the digital pins in the breadboard in the same row as open-ended jumper cables and 10k ohm resistors. I did this process four times to create 4 switches, and therefore 4 different notes on my instrument. I connected one cable to the 5v power in the breadboard, and left the other end loose. I then added male to female extensions onto the 5 open-ended cables, and put conductive tape on their ends. Lastly, I taped these tabs to the fingers of a single glove -- placing the 5v cable on the thumb, and the 4 cables connected to digital pins to the other 4 fingers. This allowed me to program each finger, allowing a different note to play when the thumb is pressed against each tab. I utilized the same code from part 3, but I added 2 more buttons and programmed each to play a different note. The pointer finger corresponds to note G4 and button 4, the middle finger corresponds to note E4 and button 3, the ring finger corresponds to note D4 and button 2, and the pinky corresponds to C4 and button 1. See code below.
testing piano glove

piano glove schematic