LED Piano With Display That Shows Note Being Played
by 804611 in Circuits > Arduino
647 Views, 5 Favorites, 0 Comments
LED Piano With Display That Shows Note Being Played
I made a LED piano. The display shows "PLAY" when nothing is being presses. LED lights up whenever you press the note and the display shows what note is being played. The last button turns the red LED on and changes the octave up one and the display shows "HI" to indicate the higher octave is active and the key note overrides both PLAY and Hi.
Supplies
Connect Power and Ground
Connect Ground and power from Arduino to BreadBoard. Bridge the top and bottom rails together.
Connect Wires From Arduino Pins to Buttons
Connect all pins from pin 2 all the way till pin 9 to the buttons, connect the opposite ends of the button to ground. Make sure all wires are securely connected and all pins are connected correctly from left to right. Add an extra wire from pin 10 to the right side and leave it for later for the buzzer
Connect the Green LEDs
Put a jumper cable from the arduino pin row on the breadboard to an empty row on the right. Take a 330 ohm resistor and bridge the jumper cable from the top of the breadboard to the bottom. Finally, connect a green LED from the resistor row to power and do for all 8 buttons. Ensure LEDs are connected to POWER and not ground and ensure all wired are secured properly.
Connect the Buzzer
Use the extra wire from before and connect the negative side of the buzzer to the same row as the wire and the positive side of the buzzer (indicated with a "+") to ground on the power rail. Ensure that the buzzer is in the correct orientation or it will not make any sound.
4 Digit 7 Segment
Connect Pin 11 and 12 all the way to the end of the breadboard, Pin 11 goes to CKL and Pin 12 goes to DIO on the display (The location is written on the back near the pins). To the left of that you have power 5V (VCC) and ground (GND) Connect these to the power and ground rails. This is to connect the 4 digit 7 segment display to show the notes and PLAY and HI
Octave Change Button
Connect the analog pin A0 to an open row on the breadboard, conned the button to the same row and connect a jumper cable in that same row too. Connect the other side of the jumper wire to the opposite side of the breadboard, connect a 330 ohm resistor from the cable row to the red LED. This will make sure the LED turns on when the button is pressed. Note: Temporary remove the display to make the wiring easy, then put it back after your done.
CODE
This is the entire code for the circuit. First set variables to pin number and item, for example: int buzzer = 10;. THis means that the buzzer pin is pin 10 on the arduino, do that for all the pins/buttons. Then set the frequencies that the buzzer will play for each note. Since we are also using a higher octave, we need to set the higher octave frequencies too. Then use Input pullup for all buttons to ensure that no inputs are misread. Then display brightness to 7 for highest brightness. Then show play on the display until a button is pressed. If a button is pressed, then it will show the note being played instead of "PLAY". Then it will show the note being played on the screen with the code and for the display to understand you need to use binary to turn on and off segments. Finally the last 4 rows of binary are to show the word PLAY in binary. This is all the code for the circuit.
Credit for original code and inspiration HERE
Play and Enjoy
Now you can play and enjoy your own piano that you made
HELP Center/Works Cited
If you are having trouble with components, use the following links for help (I used them too)
Arduini Help center
Works cited:
https://www.instructables.com/How-to-Write-a-Good-Electronics-Instructable/