Project 7 Expansion: “Ode to Joy”

This post is by a newbie, for newbies. As far as I can tell, it does not duplicate any previous post.

Once you have completed Project 7, it is possible to expand the “keyboard” so you can play “Ode to Joy”. This post gives the recipe, plus instructions on how to play the tune on your improved six-button instrument.

It assumes you have already built the circuit as it appears on page 80 of the Arduino Projects Book, copied the code, and used the four-button keyboard successfully.

The notes that are called “middle C, D, E and F (262Hz, 294Hz, 330Hz and 394Hz)” on page 82 are called C4, D4, E4 and F4 on the chart of frequencies of music on the Michigan Tech web site here. The additional buttons you need will generate notes G3 (196Hz) and G4 (392Hz). They are (perhaps obviously) lower and higher, respectively, than four frequencies already in place, so the “new” buttons will be one each on the left and the right of the original four. If you start on the left-most row of the breadboard, there is enough space for the six keys and the piezo (see photo below).

I am not an electrician and arrived at the configuration of resistors by trial and error. If I'm reading the resistor color codes correctly, they should be (from left to right in photo) 10kilohm, 1megaohm, 10kilohm, 4.7kilohm, 1kilohm, 220ohm.

The code should be changed as follows:
the array “notes” (line 1) should be changed from {262,294,330,349} to {196,262,294,330,349,392}
the long if-statement at the end should read

if (keyVal == 1023) {
tone (8, notes[0]);
}
else if (keyVal >= 990 && keyVal <= 1010){
tone(8, notes[1]);
}
else if (keyVal >= 920 && keyVal <= 940){
tone(8, notes[2]);
}
else if (keyVal >= 685 && keyVal <= 705){
tone(8, notes[3]);
}
else if (keyVal >= 505 && keyVal <= 515){
tone(8, notes[4]);
}
else if (keyVal >= 5 && keyVal <= 10){
tone(8, notes[5]);
}
else{
noTone(8 );
}

Those are all the modifications you need to make.

Below the “score”, first presented as musical notes with German lyrics, then as button numbers (from left to right in the picture) with English lyrics

D D C G3 G3 C D E
Freude, schöner Götterfunken,
F F E D D E E
Tochter aus Elysium,
D D C G3 G3 C D E
Wir betreten feuertrunken,
F F E D E F F
Himmlische, dein Heiligthum!
E E D F E-D C D F
Deine Zauber binden wieder
E D C D F-F E G4
Was die Mode streng geteilt;
D D C G3 G3 D D E
Alle Menschen werden Brüder,
F F E D E F F
Wo dein sanfter Flügel weilt.

3 3 2 1 1 2 3 4
Joy, beautiful sparkle of god,
5 5 4 3 3 4 4
Daughter of Elysium,
3 3 2 1 1 2 3 4
We enter, fire-drunken,
5 5 4 3 4 5 5
Heavenly one, your shrine.
4 4 3 5 4 3 2-3 5
Your magics bind again
4 3 2 3 5 5 4 6
What custom has strictly parted
3-3 2 1 1 2 3 4
All men become as brothers
5 5 4 3 4 5 5
Where your tender wing lingers.

“Ode to Joy” on the Arduino is my second-favorite version of “Ode to Joy”. My favorite version is here.