Elegoo Arduino Uno R3 – “Tone Keyboard” Project

Image Source:  Reporter

Image Source: Reporter

By: Valerie Lai, Reporter

In this step-by-step document, I will show you how to make a tone keyboard using the Elegoo Uno R3 Starter Kit.

Here are your materials –

  • Button (3x)
  • Short Wires (11x)
  • Passive Buzzer (1x)
  • Resistor (4x)
  • Breadboard
  • Elegoo Uno R3

Steps:

  1. Lay your Elegoo on the left of the breadboard, and connect two of the wires at the bottom of the breadboard – one from the negative on the left to the negative on the right, and the other from the positive on the left and the positive on the right.
  2. Next, insert the legs of your buzzer into 3E and 3F. Add a resistor to J3 and -3 on the right. This way, the resistor can connect to the buzzer since it’s on the same row.
  3. Afterwards, put your buttons (3x) at 13E/13F/15E/15F (button 1), 17E/17F/19E/19F (button 2), and 21E/21F/23E/23F (button 3).
  4. Then, put 3 wires in at 15J/+15, 19J/+19, and 23J/+23. Take 3 resistors and add them to 13J/-13, 17J/-17, and 21J/-21.
  5. By now, your project should look like this.
  6. Now, we will start connecting the Elegoo. Take a small wire and connect it from pin 8 on the Elegoo to 3C on your breadboard. Then, take another two wires and connect them using 5V/+3 and GND/-3.
  7. Add three more wires to A0/13C, A1/17B, and A2/21A.
  8. Now, you are all done with the physical portion of your project!

Pictures to correspond with the steps:

Here is what your code should look like (you can copy and paste):

/*
Keyboard

Plays a pitch that changes based on a changing
input circuit:
* 3 pushbuttons from +5V to analog in 0 through
3
* 3 10K resistors from analog in 0 through 3 to
ground
* 8-ohm speaker on digital pin 8
*/

int pos = 0;

void setup()
{
pinMode(A0, INPUT);
pinMode(8, OUTPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
}

void loop()
{
// if button press on A0 is detected
if (digitalRead(A0) == HIGH) {
tone(8, 554, 100); // play tone 61 (C#5 = 554 Hz)
}
// if button press on A1 is detected
if (digitalRead(A1) == HIGH) {
tone(8, 622, 100); // play tone 63 (D#5 = 622 Hz)
}
// if button press on A0 is detected
if (digitalRead(A2) == HIGH) {
tone(8, 698, 100); // play tone 65 (F5 = 698 Hz)
}
delay(10); // Delay a little bit to improve simulation performance
}

Now, you are all done!!!