Audrino Mini Piano - Harvir

by 776704 in Circuits > Arduino

15 Views, 1 Favorites, 0 Comments

Audrino Mini Piano - Harvir

IMG_8085.jpg
IMG_8086.jpg

I created a mini piano using an Arduino Uno. The piano plays different musical notes when buttons are pressed. I also added LEDs to the different types of notes being played and I included an LDR Sensor that changes the pitch of the notes based on the brightness of the environment.



Supplies

  1. Arduino
  2. Jumper wires
  3. Breadboard
  4. Buzzer
  5. 7 Pushbutton switches
  6. Red led light
  7. Yellow led light
  8. Green led light
  9. LDR sensor
  10. 3 x 330 ohms resistors
  11. 1 x 10k ohms resistor

Placing the Pushbuttons

IMG_8074.jpg

Place 7 pushbuttons and connect them to ground. Each button represents a different musical note (C, D, E, F, G, A, B).

Placing LEDs and Resistors

IMG_8075.jpg

Place 3 Led lights and connect the short leg to a 330 Ohms resistor to ground. Red LED for low notes (C and D)

Yellow LED for middle notes (E, F, and G) Green LED for high notes (A and B)

Placing the Buzzer

IMG_8076_2.jpg

Place a Buzzer on the circuit and connect it to ground. The buzzer is the output device that creates sound when a button is pressed.

Placing the LDR Sensor

IMG_8076.jpg

Place a LDR on the circuit and connect one leg to 5V and connect the other leg to a 10k Ohms resistor to ground.

Wiring the Pushbuttons and LEDS

IMG_8085_2.jpg

Wire the pushbuttons to pins 2-8 And the LEDs from pins 10-12

Notes:

  1. C = Pin 8
  2. D = Pin 7
  3. E = Pin 6
  4. F = Pin 5
  5. G = Pin 4
  6. A =Pin 3
  7. B = Pin 2

LEDs:

  1. Red = Pin 10
  2. Yellow = Pin 11
  3. Green = Pin 12

Wiring the Buzzer and LDR Sensor

IMG_8086_3.jpg

Wire the buzzer to Pin 9 and wire the LDR to A0

Connecting the Circuit to Power

IMG_8088.jpg

Connect the circuit to ground and power.

Building the Code

Screenshot 2026-06-17 at 1.52.23 PM.png
Screenshot 2026-06-17 at 1.53.03 PM.png
Screenshot 2026-06-17 at 1.53.25 PM.png
Screenshot 2026-06-17 at 1.53.50 PM.png

Build your code. I created my code using thinkercad. The code allows the Arduino to read button inputs, play different notes through the buzzer, control the LEDs, and use the LDR sensor to change the pitch. I used a code from this website: https://projecthub.arduino.cc/rahulkhanna/arduino-tutorial-mini-piano-0c7ec5 But I added on to it to make sure my LDR and LED lights work.

Each pushbutton is assigned to a musical note:

  1. C = 262 Hz
  2. D = 294 Hz
  3. E = 330 Hz
  4. F = 349 Hz
  5. G = 392 Hz
  6. A = 440 Hz
  7. B = 493 Hz

The LEDs show what range of notes are being played:

  1. Red LED turns on for low notes (C and D)
  2. Yellow LED turns on for middle notes (E and F)
  3. Green LED turns on for high notes (G, A and B)

The LDR sensor reads the amount of light using the analog pin A0. The code checks the light level and changes the pitch:

  1. Bright light = normal pitch
  2. Dark light = high pitch


Testing the Piano

After uploading the code, I tested each part of the piano.

  1. Pressing each button played a different note.
  2. The correct LED turned on depending on the note range.
  3. The LDR detected changes in light and adjusted the pitch.
  4. The buzzer playing the right sound.
  5. Fixing any problems on the circuit