Introduction: Mini Piano With Arduino 101

This is a mini piano board with only 4 customizable buttons allowing you to play any frequency and tone you want. It is a simple yet fun toy to build especially for kids!

Here's also a recording of my happy birthday-twinkle twinkle Arduino remix!

Step 1: Materials and Tools

  • Arduino
  • 4x Push button switches
  • 4x 10kΩ resisitor
  • 6x jumper wires
  • Breadboard wires
  • Breadboard

Step 2: Connecting to Ground

  • Connect one of the pins of each of the switches to ground.
  • Connect one of the buzzer pins to ground.

It doesn't matter which one you connect since the remaining pin will be the signal pin.

Step 3: Connecting the Resistors

  • Connect each of the 10kΩ resistor between power (red power rail) to one of the pins of each switch, this is also known as the signal pin.
  • Connect this power rail to 3.3V.

Step 4: Connecting the Signal

  • Connect the signal pin of each switch to pins 2-5 on the Arduino.

Step 5: Coding and Uploading

Upload the following code to your Arduino, once you have selected the appropriate board and port under tools.

const int yellow = 2;
const int green = 3; const int blue = 4; const int red = 5; const int buzz = 6;
int notes[] = {262,294,330,349};
void setup() {
  pinMode (yellow, INPUT);
  pinMode (green, INPUT);
  pinMode (blue, INPUT);
  pinMode (red, INPUT);
  pinMode (buzz, OUTPUT);
  tone (buzz, 2000);
void loop() {
  if (digitalRead(yellow) == LOW)
    {tone(buzz, notes[0], 50);
    delay (50);
  else if (digitalRead(green) == LOW)
    {tone (buzz, notes[1], 50);
    delay (50);
  else if (digitalRead(blue) == LOW)
    {tone (buzz, notes[2], 50);
    delay (50);
  else if (digitalRead(red) == LOW)
   {tone (buzz, notes[3],50);
    delay (50);
    noTone (buzz);

Step 6: Demo

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017