Categories
Practical Project

The adventure!

Untitled sketch bb xtzeuuzjoe
Circuit diagram to follow

Step 1. Attaching the pushbuttons the breadboard.

I attached it first as it was a good starting point. Evenly spacing them out is helpful to keeping everything organised.

Here’s what it looks like once all 7 pushbuttons are attached. I adjusted the buttons as I realized there was not enough space to put the wires above the push buttons. I could have put it below however to make things easier, I just followed the diagram.

Step 2. Attach Jumper wires.

I began with just grounding each of the push buttons. All of the white wires have the same function.

After grounding all the pushbuttons I started with connecting the jumper wires from the breadboard to the arduino uno.

These are how the connections went:

Pushbutton C – D10, D – D9, E – D8, F – D7, G – D6, A – D5, B -D4

Step 3. Attach the piezo buzzer to the breadboard and arduino.

For the connection from the piezo speaker to the breadboard attach the piezo speaker ground to the breadboard ground and the positive terminal to the Arduino. Once this is done ensure all the connections are set properly.

Implement the code

Once the circuit as been doublechecked, it is time to run the code through the Arduino and begin testing. I did not have to modify it as my configuration was the same.

This is the code that needs to be uploaded before the “piano” is working.

define T_C 262

define T_D 294

define T_E 330

define T_F 349

define T_G 392

define T_A 440

define T_B 493

const int C = 10;
const int D = 9;
const int E = 8;
const int F = 7;
const int G = 6;
const int A = 5;
const int B = 4;

const int Buzz = 11;
const int LED = 13;

void setup()
{
pinMode(LED, OUTPUT);
pinMode(C, INPUT);
digitalWrite(C,HIGH);

pinMode(D, INPUT);
digitalWrite(D,HIGH);

pinMode(E, INPUT);
digitalWrite(E,HIGH);

pinMode(F, INPUT);
digitalWrite(F,HIGH);

pinMode(G, INPUT);
digitalWrite(G,HIGH);

pinMode(A, INPUT);
digitalWrite(A,HIGH);

pinMode(B, INPUT);
digitalWrite(B,HIGH);

digitalWrite(LED,LOW);
}

void loop()
{
while(digitalRead(C) == LOW)
{
tone(Buzz,T_C);
digitalWrite(LED,HIGH);
}

while(digitalRead(D) == LOW)
{
tone(Buzz,T_D);
digitalWrite(LED,HIGH);
}

while(digitalRead(E) == LOW)
{
tone(Buzz,T_E);
digitalWrite(LED,HIGH);
}

while(digitalRead(F) == LOW)
{
tone(Buzz,T_F);
digitalWrite(LED,HIGH);
}

while(digitalRead(G) == LOW)
{
tone(Buzz,T_G);
digitalWrite(LED,HIGH);
}

while(digitalRead(A) == LOW)
{
tone(Buzz,T_A);
digitalWrite(LED,HIGH);
}

while(digitalRead(B) == LOW)
{
tone(Buzz,T_B);
digitalWrite(LED,HIGH);
}

noTone(Buzz);
digitalWrite(LED,LOW);

}

Now it is time to test the piano by playing some melodies.

Melodies

List of melodies to replicate: Still Dre by Dr Dre, ABC by Jackson 5, What a wonderful world by Louis Armstrong

Dr Dre Next episode
ABC by Jackson 5
Spider man theme

Leave a Reply

Your email address will not be published.