Site icon Circuit Ideas for You

Arduino Piano Music Keyboard with Memory Circuit

This project is for Arduino Piano Music Keyboard with Memory Circuit.

Main parts are Arduino Uno, push buttons, buzzer, LCD and resistors.

When button is press then buzzer make piano sound.

LCD show note name on screen.

We can record notes and play again later.

It is small and fun project.

Good for learning Arduino, electronics and music.

Circuit Coding:

#include <LiquidCrystal.h>
#include <Tone.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int buzzer = 10;
int keys[8] = {A0, A1, A2, A3, A4, A5, 6, 7};
int notes[8] = {262, 294, 330, 349, 392, 440, 494, 523};
int recordData[100];
int recordTime[100];
int index = 0;
bool recording = false;
unsigned long lastTime;

void setup() {
lcd.begin(16,2);
lcd.print("Arduino Piano");
for(int i=0;i<8;i++){
pinMode(keys[i],INPUT);
}
pinMode(buzzer,OUTPUT);
delay(1000);
lcd.clear();
}

void loop() {
for(int i=0;i<8;i++){
if(digitalRead(keys[i])==HIGH){
tone(buzzer,notes[i],300);
lcd.setCursor(0,0);
lcd.print("Note: ");
lcd.print(notes[i]);
if(recording){
recordData[index] = notes[i];
recordTime[index] = millis()-lastTime;
lastTime = millis();
index++;
}
delay(300);
}
}
if(digitalRead(8)==HIGH){
recording = true;
index = 0;
lastTime = millis();
lcd.clear();
lcd.print("Recording...");
delay(500);
}
if(digitalRead(9)==HIGH){
lcd.clear();
lcd.print("Playing...");
for(int j=0;j<index;j++){
delay(recordTime[j]);
tone(buzzer,recordData[j],300);
}
recording = false;
delay(500);
}
}

Code Explanation:

Circuit Working:

Parts List:

ComponentValueQuantity
Resistors (All resistors are 1/4 watt unless specified)10k 3
560Ω1
1.5k1
2.6k1
3.9k1
5.6k1
6.8k 1
8.2k 1
Preset 10k1
SemiconductorsArduino UNO Board1
LCD Display 16×21
Piezo Buzzer 1
Tactile Switches S1 to S8 piano keys8
Record Tactile Switch 1
Replay Tactile Switch 1

Arduino Uno is brain of project.

Total 10 tactile switches are used.

8 buttons work as piano keys.

2 extra buttons are near buzzer and LCD.

One for Record and one for Replay.

When button is press then Arduino check which one.

Each button send signal to Arduino.

Arduino play tone on buzzer for that button.

LCD also show note name.

VR1 preset use for LCD contrast adjust.

Power come from Arduino 5V and GND to breadboard rails.

Resistors used as pull down for buttons.

If record mode is ON then Arduino save notes with time gap.

If replay button is pressed then Arduino read saved notes and play again with same timing.

Formulas:

Frequency of tone is given by formula:

f = 1/T

where,

Arduino tone function use square wave.

How to Build:

To build a Arduino Piano Music Keyboard with Memory Circuit follow the below steps for connections:

First collect all parts same like circuit diagram.

Push button connections:

Buzzer connections:

LCD connections:

Preset connections:

Conclusion:

This Arduino Piano Music Keyboard with Memory Circuit is simple project.

It is small and fun to make.

Project show how to use buttons, buzzer, LCD and memory in Arduino.

We can add more notes in future.

We can use better buzzer or speaker.

Also can use SD card for saving songs.

It is a good project for learning embedded system.

This circuit is nice DIY music toy for beginners.

References:

Help Turn a toy Keyboard (piano) into a MIDI Device (Arduino uno)

Exit mobile version