กลับไปหน้ารวมไฟล์
mini-piano-3cd923-en.md

The Arduino-based Mini Piano project helps in understanding the sound capabilities of Arduino. The project focuses on Arduino’s ability to generate different tones. The Arduino Uno microcontroller can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. One of the senses on which our project focuses is sound. We have created a miniature version of a piano that produces notes like a normal piano.

How does it work?

After completing the connections and uploading of code to the board, connect a 9v battery as a source of power to the Arduino. When you press the respective pushbuttons, you can hear the corresponding notes played through the piezo buzzer. You can adjust the tone value in the source code and try with different pitches.

Code Explanation.

int pb1 = 2;
int pb2 = 3;
int pb3 = 4;
int pb4 = 5;
int pb5 = 6;
int pb6 = 7;
int pb7 = 8;
int pb8 = 9;
int buzz = 13;

Here, I have declared all the Push Button pins as pb1, pb2, pb3, and so on. And declared the buzzer pin as "buzz".

pinMode(pb1,INPUT);
pinMode(pb2,INPUT);
pinMode(pb3,INPUT);
pinMode(pb4,INPUT);
pinMode(pb5,INPUT);
pinMode(pb6,INPUT);
pinMode(pb7,INPUT);
pinMode(pb8,INPUT);
pinMode(buzz,OUTPUT);

Here, I have declared whether Arduino UNO should accept the INPUT or give the OUTPUT.

tone(buzz,262,100);

The tone function has three parts:-pin, frequency, duration.

  • In the Pin, you should give the Digital pin no. where the buzzer is connected.
  • In the frequency, you should give the value of frequency(Hz) you want.
  • In the duration, you have to give for how many milliseconds should the tone play, it is measured in milliseconds.

This is my youtube channel video on how to prepare Mini Piano

You-Tube Video

Hope you liked this mini-project!! Follow and like this project for more Arduino Projects

Don't forget to Subscribe to my Youtube channel and click on the bell icon for notifications.

EXPANDED TECHNICAL DETAILS

Tactile Polyphonic Sound Hub

A creative and compact digital piano project that uses tactile buttons and a custom sound engine to play musical notes.

  • Chromatic LUT Mapping: The Arduino monitors a row of tactile switches. The firmware uses a pre-defined Look-Up Table (LUT) to map each button to its precise frequency (e.g., Middle C = 261.63Hz).
  • Square-Wave Audio Pulse: Uses the tone() function to generate the musical notes. The project explores the use of a simple low-pass filter to soften the "Digital" sound of the square waves, resulting in a warmer, more pleasant tone.

Prototyping

  • Web Editor validated: The melodic logic was refined in the Arduino Web Editor, ensuring the piano remains responsive with zero lag between physical press and acoustic feedback.

ข้อมูล Frontmatter ดั้งเดิม

title: "🎼🎹Mini Piano🎹🎼"
description: "Building a miniature piano using Arduino UNO. The 8 customizable buttons allow you to play any frequency and tone u want."
author: "harsha123456"
category: ""
tags:
  - "audio"
  - "mini"
  - "music"
  - "piano"
views: 4453
likes: 3
price: 870
difficulty: "Intermediate"
components:
  - "8x Resistor 10k ohm"
  - "8x Tactile Switch, Top Actuated"
  - "1x 9V battery (generic)"
  - "1x Buzzer, Piezo"
  - "1x Arduino UNO"
  - "1x Solderless Breadboard Full Size"
  - "11x Jumper wires (generic)"
tools: []
apps:
  - "1x Arduino Web Editor"
downloadableFiles: []
documentationLinks: []
passwordHash: "1b7c769632bae6f6dc6060cfdab289496b67797e3eaf4417a136b6713a363b12"
encryptedPayload: "U2FsdGVkX1/uoID0RBzgTZfMD+bcNho/FgwQsnOk64bhMQmXVmyqovp6wnL4tY3WqR8VfLHrEQYlnACY60aHrPwSMGVgYczRttSAW2smZAU="
seoDescription: "Build a Mini Piano with Arduino UNO. Features 8 customizable buttons to play any frequency and tone. A perfect DIY project for music lovers."
videoLinks:
  - "https://www.youtube.com/embed/QGn40en8ntQ"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/mini-piano-3cd923_cover.jpg"
lang: "en"