Overview
For our project we created an Arduino piano. We programmed it so that the state of a button triggers it to play individual notes. It combines the basic circuits of the buzzer and the buttons. We used a really long breadboard because it allows us to only need to use one board. Then all the button are linked to the circuit board and the buzzer is as well. In the end each button press corresponds a staccato beep of a certain note. In a nutshell, the programming says that if a certain button is in a certain state, then a sound with a predetermined frequency will be made by the buzzer. If no button is in the aforementioned state, then no sound is made.
Content
Electricity- the flow of energy between charged electrons
Voltage- potential energy difference through an obstacle with resistance
Current- "flow" of electricity through a circuit
Circuit- a loop of conductive material that connects the negative and positive sides of a power source
Resistance- measure of how much current is slowed
Power- rate at which energy is transferred by a circuit
Reflection
I think this project went well as far as teamwork goes. I would say we worked well together , we were able to get through the packet relatively easily and met all the deadlines on time. One of our peaks was that we cooperated easily. We didn't have a lot of conflicts in where we wanted to go with the project, and we worked efficiently as a team. This made the project a lot easier and allowed us to finish early. I found that being able to cooperate well with a partner really helps in group work. When I compare this group to others where I had a harder time working with people, this one was easier by far. One of my pits was that I was easily distracted. I was off task more than I would like to admit, and that put a larger workload on my partner. Although we finished early, we would have finished earlier if I had been less distracted. Next time for my teammates' sake, I will work harder to do my share of the work.
Our Code
int button_C = 2; //Defining Button_C as pin 2
int button_D = 3;
int button_E = 4;
int button_F = 5;
int button_G = 6;
int button_A = 7;
int button_B = 8;
int button_Cup = 9; //Cup means C one octave above C
int speaker = 13; //Defining the speaker as pin 13
int buttonstate_C = 0; //The un-pressed buttons mean the button is off
int buttonstate_D = 0;
int buttonstate_E = 0;
int buttonstate_F = 0;
int buttonstate_G = 0;
int buttonstate_A = 0;
int buttonstate_B = 0;
int buttonstate_Cup = 0;
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; //All the frequencies the speaker needs (C, b, a, g, f, e, d, c)
int Cur_tone = 0; //Speaker will not make noise unless button is activated
void setup() { //Perform this part of the code once
pinMode(button_C, INPUT); //button_C will be an input of electricity (cause of the outcome)
pinMode(button_D, INPUT);
pinMode(button_E, INPUT);
pinMode(button_F, INPUT);
pinMode(button_G, INPUT);
pinMode(button_A, INPUT);
pinMode(button_B, INPUT);
pinMode(button_Cup, INPUT);
pinMode(speaker, OUTPUT); //Everything that happens in the circuit will go to the speaker eventually
}
void loop() { //What the code will actually do from a human perspective
buttonstate_C = digitalRead(button_C); //define or rename buttonstate_C as button_C for easier typing because we are lazy
buttonstate_D = digitalRead(button_D);
buttonstate_E = digitalRead(button_E);
buttonstate_F = digitalRead(button_F);
buttonstate_G = digitalRead(button_G);
buttonstate_A = digitalRead(button_A);
buttonstate_B = digitalRead(button_B);
buttonstate_Cup = digitalRead(button_Cup);
if((buttonstate_C == HIGH) || (buttonstate_E == HIGH) || //the beginning of an if then statement
(buttonstate_G == HIGH) || (buttonstate_D == HIGH) ||
(buttonstate_F == HIGH) || (buttonstate_A == HIGH) ||
(buttonstate_B == HIGH) || (buttonstate_Cup == HIGH) )
{
if (buttonstate_C == HIGH) //getting more specific if button is activated, play tone 0, or play a tone with a frequency of 1915
{
Cur_tone = tones[0]; //play tone 0, or play a tone with a frequency of 1915
}
if (buttonstate_E == HIGH)
{
Cur_tone = tones[2];
}
if (buttonstate_G == HIGH)
{
Cur_tone = tones[4];
}
if (buttonstate_D == HIGH)
{
Cur_tone = tones[1];
}
if (buttonstate_F == HIGH)
{
Cur_tone = tones[3];
}
if (buttonstate_A == HIGH)
{
Cur_tone = tones[5];
}
if (buttonstate_B == HIGH)
{
Cur_tone = tones[6];
}
if (buttonstate_Cup == HIGH)
{
Cur_tone = tones[7];
}
digitalWrite(speaker, HIGH); //if buttons are activated, activate speakers
delayMicroseconds(Cur_tone); //no delay between button and speaker
digitalWrite(speaker, LOW); //after button is released, stop playing a tone
delayMicroseconds(Cur_tone); //also no delay between button and speaker
}
else //if no speaker is pressed, then
{
digitalWrite(speaker, LOW); //turn the speaker off.
}
}
For our project we created an Arduino piano. We programmed it so that the state of a button triggers it to play individual notes. It combines the basic circuits of the buzzer and the buttons. We used a really long breadboard because it allows us to only need to use one board. Then all the button are linked to the circuit board and the buzzer is as well. In the end each button press corresponds a staccato beep of a certain note. In a nutshell, the programming says that if a certain button is in a certain state, then a sound with a predetermined frequency will be made by the buzzer. If no button is in the aforementioned state, then no sound is made.
Content
Electricity- the flow of energy between charged electrons
Voltage- potential energy difference through an obstacle with resistance
Current- "flow" of electricity through a circuit
Circuit- a loop of conductive material that connects the negative and positive sides of a power source
Resistance- measure of how much current is slowed
Power- rate at which energy is transferred by a circuit
Reflection
I think this project went well as far as teamwork goes. I would say we worked well together , we were able to get through the packet relatively easily and met all the deadlines on time. One of our peaks was that we cooperated easily. We didn't have a lot of conflicts in where we wanted to go with the project, and we worked efficiently as a team. This made the project a lot easier and allowed us to finish early. I found that being able to cooperate well with a partner really helps in group work. When I compare this group to others where I had a harder time working with people, this one was easier by far. One of my pits was that I was easily distracted. I was off task more than I would like to admit, and that put a larger workload on my partner. Although we finished early, we would have finished earlier if I had been less distracted. Next time for my teammates' sake, I will work harder to do my share of the work.
Our Code
int button_C = 2; //Defining Button_C as pin 2
int button_D = 3;
int button_E = 4;
int button_F = 5;
int button_G = 6;
int button_A = 7;
int button_B = 8;
int button_Cup = 9; //Cup means C one octave above C
int speaker = 13; //Defining the speaker as pin 13
int buttonstate_C = 0; //The un-pressed buttons mean the button is off
int buttonstate_D = 0;
int buttonstate_E = 0;
int buttonstate_F = 0;
int buttonstate_G = 0;
int buttonstate_A = 0;
int buttonstate_B = 0;
int buttonstate_Cup = 0;
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 }; //All the frequencies the speaker needs (C, b, a, g, f, e, d, c)
int Cur_tone = 0; //Speaker will not make noise unless button is activated
void setup() { //Perform this part of the code once
pinMode(button_C, INPUT); //button_C will be an input of electricity (cause of the outcome)
pinMode(button_D, INPUT);
pinMode(button_E, INPUT);
pinMode(button_F, INPUT);
pinMode(button_G, INPUT);
pinMode(button_A, INPUT);
pinMode(button_B, INPUT);
pinMode(button_Cup, INPUT);
pinMode(speaker, OUTPUT); //Everything that happens in the circuit will go to the speaker eventually
}
void loop() { //What the code will actually do from a human perspective
buttonstate_C = digitalRead(button_C); //define or rename buttonstate_C as button_C for easier typing because we are lazy
buttonstate_D = digitalRead(button_D);
buttonstate_E = digitalRead(button_E);
buttonstate_F = digitalRead(button_F);
buttonstate_G = digitalRead(button_G);
buttonstate_A = digitalRead(button_A);
buttonstate_B = digitalRead(button_B);
buttonstate_Cup = digitalRead(button_Cup);
if((buttonstate_C == HIGH) || (buttonstate_E == HIGH) || //the beginning of an if then statement
(buttonstate_G == HIGH) || (buttonstate_D == HIGH) ||
(buttonstate_F == HIGH) || (buttonstate_A == HIGH) ||
(buttonstate_B == HIGH) || (buttonstate_Cup == HIGH) )
{
if (buttonstate_C == HIGH) //getting more specific if button is activated, play tone 0, or play a tone with a frequency of 1915
{
Cur_tone = tones[0]; //play tone 0, or play a tone with a frequency of 1915
}
if (buttonstate_E == HIGH)
{
Cur_tone = tones[2];
}
if (buttonstate_G == HIGH)
{
Cur_tone = tones[4];
}
if (buttonstate_D == HIGH)
{
Cur_tone = tones[1];
}
if (buttonstate_F == HIGH)
{
Cur_tone = tones[3];
}
if (buttonstate_A == HIGH)
{
Cur_tone = tones[5];
}
if (buttonstate_B == HIGH)
{
Cur_tone = tones[6];
}
if (buttonstate_Cup == HIGH)
{
Cur_tone = tones[7];
}
digitalWrite(speaker, HIGH); //if buttons are activated, activate speakers
delayMicroseconds(Cur_tone); //no delay between button and speaker
digitalWrite(speaker, LOW); //after button is released, stop playing a tone
delayMicroseconds(Cur_tone); //also no delay between button and speaker
}
else //if no speaker is pressed, then
{
digitalWrite(speaker, LOW); //turn the speaker off.
}
}