Second round + Code explained

Round 2 stock image to represent that it is the second prototype

For the second prototype, the idea for the overall improvement came to me when I was trying to record all my selected melodies. The reason was because I had run into a major problem when playing the melodies, some melodies required sharps and flats and my mini instrument physically could not play them as there were not enough push buttons. I will also breakdown the code block by block in this blog as it would be a very boring blog since the modifications are minimal (yet significant).

This setup was the same as the original however this post will still go step by step and detail what was modified or added. The yellow highlight will represent this.

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 11 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, CD – D12, D – D9, DE – D13, E – D8, F – D7, FG – D3, G – D6, GA -D2. 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.

The Code

The code was original not mine and found online from the Arduino page linked here. First of before any of the code is typed up, You must ensure that another piece of code called tone.h are in your library directory within your files. This can be found here on github. What this tone.h file allows the user to do is define notes within arduino in order to be played on the instrument. It ensures that the code can understand my define commands.

Tone folder with library contains tone.h
tone.h allows this to funcntion. The number next to the note represents the frequency of the note.

The next block of code represents which pin will be connected to what. For example we can see that the number 11 correlates to pin 11 on the Arduino and it says buzzer so it is connected to the piezo buzzer. If I were to change the number to 10 all I would have to ensure is that the connection is changed to pin 10.

These next 2 blocks of code represent how the function is triggered and how it is outputted. We can see that it says input and pin mode. All this means is the pushbutton will trigger it and the output with the tone buzz quite literally means how it will be outputted. The letters on each of the different lines correlate with the pin and frequency connections mentioned beforehand.

Leave a Reply

Your email address will not be published.