Sie sind auf Seite 1von 28

ARDUINO BASED PIANO PIEZO BUZZER

MINI PROJECT REPORT

Submitted by

PRANESH S (161EC222)

NAVEEN KUMAR B (161EC207)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING
BANNARI AMMAN INSTITUTE OF TECHNOLOGY
(An Autonomous Institution Affiliated to Anna University, Chennai)
SATHYAMANGALAM-638401

APRIL 2019
ARDUINO BASED PIANO PIEZO BUZZER
MINI PROJECT REPORT

Submitted by

PRANESH S (161EC222)

NAVEEN KUMAR B (161EC207)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING
BANNARI AMMAN INSTITUTE OF TECHNOLOGY
(An Autonomous Institution Affiliated to Anna University, Chennai)
SATHYAMANGALAM-638401

APRIL 2019
BONAFIDE CERTIFICATE

Certified that this project report “ARDUINO BASED PIANO PIEZO


BUZZER” is the bonafide work done of “S.PRANESH (161EC222), &
NAVEENKUMAR B(161EC207)” who carried out the mini project work under
my supervision.

SIGNATURE SIGNATURE
Dr.C.POONGODI, Dr.C.POONGODI,
HEAD OF THE DEPARTMENT, PROFESSOR AND HEAD,
DEPARTMENT OF ECE, DEPARTMENT OF ECE,
BANNARI AMMAN INSTITUTE BANNARI AMMAN INSTITUTE
OF TECHNOLOGY, OF TECHNOLOGY,
SATHYAMANGALAM-638401. SATHYAMANGALAM-638401.

Submitted for the Viva-Voce examination held on ………………

INTERNAL EXAMINER EXTERNAL EXAMINER


TABLE OF CONTENTS

CHAPTER NO DESCRIPTION PAGE NO

ABSTRACT I
LIST OF FIGURES II
LIST OF SYMBOLS III

1 INTRODUCTION 1
NEED OF THE SYSTEM 2

2 LITERATURE REVIEW 3

3 HARDWARE COMPONENTS 4
3.1 CIRCUIT DIAGRAM 4
3.2 PUSH BUTTONS 5
3.3 ARDUINO (UNO) 7
3.4 BUZZER 9
3.5 TECHNIQUES USED IN ARDUINO 11

4 WORKING AND CONCEPT 12

5 RESULT AND DISCUSSION 17

6 CONCLUSION 19
6.1 FUTURE SCOPE 20

7 REFERENCE 21
ABSTRACT

In the recent days, piano is an musical instruments and that is used to play sounds
according to our tune and it is played by using an keyboard. This is an new-
technology where we can record and play sounds according to our interest. Also,
it also leads to emerging to new discoveries and technologies like we can play
any musical instruments with the help of Arduino platform. A special feature of
this piano project is that Arduino will record the last played set of tones and it
will repeat those tones like a one time record and repeat feature. This project
doesn’t include or have any Real-Time Applications but can be used to
understand certain features of Arduino like its sound producing capabilities using
the tone() function. Arduino has been an boon to many people who are not from
electronics department or the background. But, this piano is just pretty with the 8
push buttons and an single buzzer. It is not going to be a conventional professional
piano but it is very close to the one that it is love to play using the push buttons
and the Piezo-buzzer. The main advantage is that in this project, we don’t need
an professional musician but here we only need an maker. We can make our tune
according to our desire and interest. This generates only Pulse Width
Modulation(PWM) signals for their operation and the recording purpose. It is also
similar to the projects like Heart Rate Monitor, Robotic Arm as well as Home
Automation Applications and so on. This project is an automation for the
professional musicians and it is an simple project to display an Piano demo
according to our tune functions and it is helpful for the beginner-level musicians.
LIST OF FIGURES:

FIG.NO NAME QUANTITY

1.1 BUZZER 1

1.2 PUSH BUTTONS 8

1.3 ARDUINO UNO 1

1.4 BREAD BOARD 1

1.5 CONNCTING WIRES AS REQUIRED


LIST OF SYMBOLS:

SYMBOL NAME
PUSH BUTTON

ARDUINO UNO

BUZZER
CHAPTER 1

INTRODUCTION

Arduino based piano piezo-buzzer is an automation application used for


the current generation those who are passionate towards the music and it is an
useful project for the beginners to develop their own tone without the help of the
popular tones Practicing and Rehersal. It is an simple project made up of
Arduino(UNO), Push Buttons, and Buzzer etc. A special feature of this project
is that Arduino will record the last played set of tones and repeat those tones like
a one time record and repeat feature. This project doesn’t have any real world
applications (at least not directly) but can be used to understand certain features
of Arduino (like its sound producing capabilities using the tone () function). It is
not going to be a conventional profession Piano but is very close to the one that
you might love to play. Here, we will be making a piano that can be used for
playing the basic song tones. For this project you don’t need to be a professional
musician but a Maker is enough for making this. The special feature is that it can
record and play the tones according to our own tones. This project will be very
useful for the beginners as well as the professionals to save their time complexity.

1.1 NEED OF THE SYSTEM:

When compared to the conventional methods, it uses only push buttons


for buttons, and buzzer for their output tone. It is very simple to play as well as
to use and also it only uses push buttons for the pressing. Without that musical
instrument and also we can play it on anywhere and it is easily transportable and
also it is light weight and easy to handle it at any locations. This technique will
be implemented in future generations but still it goes on for the research.It finds
application in many Automation projects such as Home automation purposes.
CHAPTER 2

LITRATURE REVIEW

Arduino has been a boon for people who are not from the electronics
background to build stuff easily. It has been a great prototyping tool or to try
something cool, in this project we are going to build a small yet fun Piano using
the Arduino .This piano is pretty much plain with just 8 push buttons and buzzer.
It uses the tone() function of Arduino to create various types of piano notes on
the speaker. To spice it up a bit we have added the recording feature in the project,
this enables us to play a tune record it and play it again repeatedly when required.
The Arduino has a handy tone() function which can be used to generate varying
frequency signals that can be used to produce different sounds using a buzzer. So
let’s understand how the function works and how it can be used with Arduino.
Before that we should know how a Piezo buzzer works. Here we apply a variable
current (frequency) for which the crystal vibrates thus producing sound. Hence in
order to make the Piezo buzzer to make some noise we have to make the Piezo
electric crystal to vibrate, the pitch and tone of noise depends on how fast the
crystal vibrates. Hence the tone and pitch can be controlled by varying the
frequency of the current. The values of pin can be any of your digital pin. I have
used pin number 8 here. The frequency that can be generated depends on the size
of the timer in your Arduino board. For UNO and most other common boards the
minimum frequency that can be produced is 31Hz and the maximum frequency
that can be produced is 65535Hz. However we humans can hear only frequencies
between 2000Hz and 5000 Hz. It will going on progress for the compatibility
considerations and to reduce the size to transport it to any locations when required
in manual mode. Using tone () function, you can generate square waves of
different frequencies but with fixed duty cycle (50%). Internally, the tone ()
function relies on the Timers of Arduino UNO (ATmega328P Microcontroller).
CHAPTER 3

HARDWARE COMPONENTS

3.1 CIRCUIT DIAGRAM:

FIGURE 1.1 ARDUINO(UNO) AND PUSH BUTTONS


3.2 PUSH BUTTON:

An push button is a simple type of switch that will controls an action in a


machine. Initially, these Push Buttons are typically made up of an hard material,
and it is usually an plastic typed material. Basically,the button surface is usually
made up of an flat shaped surface to Accomdate the human finger, and also it
can be easily pressed or pushed based upon the user’s pressing movement.

They are mostly found on the biased switches, many unbiased buttons will
requires an spring to return to their un-pushed state depending upon their
operation. The Push buttons are also used or seen in the calculators, telephones,
and Kitchen Appliances . The Red push buttons have large heads for their
operation and to control the stopping of the machine.

FIGURE 1.2 GENERAL PUSHBUTTON

The push buttons are also used to avoid the controller by pushing the incorrect
switch , also these are often colored code to access them for their operation.
Mostly used colors are red for stopping the machine and green for starting the
machine. The mostly used colors are red for the stopping of the process and
green for starting the process.
FIGURE 1.3 OCTAGON BUTTON

These red buttons also has larger heads for their simple operation and to control
the stop of a machine. These red buttons are also called as an Immediate button
and are mandated by the electrical code.

FIGURE 1.4 THE GENERIC ARCADE GAME BUTTONS

In popular culture the phrase "the button" (sometimes capitalized) refers to a


(usually fictional) button that a military or government leader could press to
launch nuclear weapons. Akin to fire alarm switches, some big red buttons, when
deployed with suitable visual and audible warnings such as flashing lights and
sirens for extreme exigent emergencies, are known as "scram switches" (from the
slang term scram, "get out of here"). Generally, such buttons are connected to
large scale functions, beyond a regular fire alarm, such as automated shutdown
procedures, complete facility power cut, fire suppression like halon release, etc.
FIGURE 1.5 BUTTONS ON A HANHELD CALCULATOR

A variant of this is the scramble switch which triggers an alarm to activate


emergent personnel to proactively attend to and go to such disasters. An air raid
siren at an air base initiates such action, where the fighter pilots are alerted and
"scrambled" to their planes to defend the base.

3.3 ARDUINO(UNO):

The Arduino is an open source computer software and hardware


company, and user’s community that will designs and then manufactures
the single board microcontrollers and then kits for building the digital devices
and interactive objects that can sense and control objects in the physical and
digital world. These boards are also available commercially in preassembled
form, or as DIY kits. The project's products were distributed as an open-source
software and hardware, which are licensed under the GNU Lesser General Public
License (LGPL) or the GNU General Public License (GPL), permitting the
manufacturer of the Arduino boards and software distribution by the partners or
anyone.
It uses an variety of micro-processors and micro- controllers. These boards were
equipped with the sets of digital and analog input/output (I/O) pins that may be
either interfaced to the various boards or Breadboards and other circuits. It
features an serial bus communications interfaces, including Universal Serial
Bus (USB), which are also used for loading the programs from the personal
computers(PC). These microcontrollers are typically programmed by using an
dialect of features from the programming languages like C and C++.

FIGURE 1.6 ARDUINO UNO

It was started around 2003 as an program for students at the Interaction Design
Institute Ivrea in Ivrea, Italy, aiming to provide an low-cost and easy way for
professionals to create the devices that interact with their environment by
using sensors and actuators. The common examples of such devices used for the
beginner hobbyists include simple robots, thermostats, and motion detectors etc.

FIGURE 1.7 ANIMATED ARDUINO


3.4 BUZZER:

A Piezo buzzer is an electronic device commonly used to produce sound.


It is also known as Beeper or Buzzer, is an audio signalling device which may
be Mechanical, Electro-Mechanical or Piezo-electric signals etc. In Arduino, it
is called Piezo-Buzzer and also it is an electrical device that makes a buzzy
noise and it is used for the signalling purposes.

FIGURE 1.8 BUZZER

Buzzers and Sounders are also known as audio alarms, audio indicators, audio
transducers, piezo buzzers, beepers and/or audible alarms. Typical uses of
buzzers and beepers include Alarm Devices, Timers, and Confirmation of user
input such as a Mouse or a Keystroke. Light weight, simple construction and low
price make it usable in various applications like car/truck reversing indicator,
computers, call bells etc.

Piezo buzzer is based on the inverse principle of piezo electricity discovered in


1880 by Jacques and Pierre Curie. It is the phenomena of generating electricity
when mechanical pressure is applied to certain materials and the vice versa is also
true. Such materials are called piezo electric materials. Piezo electric materials
are either naturally available or man-made. Piezo-ceramic is class of manmade
material, which poses piezo electric effect and is widely used to make disc, the
heart of piezo buzzer. It can be split into two devices: Piezo and Electro-
Mechanical devices. piezo sounders contain a piezo electric vibration plate (also
known as a piezo element) within a Moulded case. Sound is emitted when a
voltage is applied and the piezo element inside the case vibrates. electro
mechanical buzzers use an electro magnet and bare metal disc. When a voltage
is applied a magnetic field is generated, causing the magnet to move and the
diaphragm to vibrate, generating an audible sound.

FIGURE 1.9 BUZZER CONFIGURATION

APPLICATIONS:

 Security and safety products


 Portable devices
 Medical equipment
 Remote monitoring systems
 Timers
 Household appliances
 Measurement and flow instruments
 Weighing machines
 User input recognition
3.5 TECHNIQUES USED IN ARDUINO:

In Arduino, it uses tone() function for their recording and playing of


the tunes. Generates a square wave of the specified frequency (and 50% duty
cycle) on a pin. In this project, we had used Arduino(UNO), Push buttons,
Piezo-buzzer for the efficient operation of the piano tone. The pin can be
connected to a piezo buzzer or other speaker to play tones. Only one tone
can be generated at a time. If a tone is already playing on a different pin, the
call to tone () will have no effect. If the tone is playing on the same pin, the
call will set its frequency. Use of the tone () function will interfere with
PWM output on pins 3 and 11 (on boards other than the Mega). Apply an
oscillating voltage to make a noise and the buzzer case supports the piezo element
and has resonant cavity for sound. Piezo buzzers exhibit the reverse piezoelectric
effect. The normal piezoelectric effect is generating electricity from squeezing a
crystal and Chan get several thousand volts, makes a spark. When the Arduino
switched on, we have to press some push buttons to start the operation and it will
starts recording for the tone that we had inserted tone. Also, here there is an
interrupt button also called as push button from that we can stop the tone that we
had recorded during the cycle or operation. The interrupt Button will stop the
recorded tone and it will play the recorded tone that we had played during the
operation or the cycle. Each button is associated with a PWM signal in the code.
When a button is pushed, that particular PWM signal is generated through the
Piezo Electric Buzzer. Now for the record and repeat mode, play a few tones by
using the different buttons for tone. With each button pressed, Arduino starts
recording i.e. makes note of the sequence of the buttons, its on time and off time.
CHAPTER 4

WORKING AND CONCEPT

WORKING:

1. Make the connections as per the circuit diagram and upload the code to
Arduino. Once the power to the circuit is turned on, Arduino is ready to accept
the input from the buttons.

2. Each button is associated with a PWM signal in the code. When a button is
pushed, that particular PWM signal is generated through the Piezo Electric
Buzzer.

3. Now for the record and repeat mode, play a few tones using different
buttons.

4. With each button pressed, Arduino starts recording i.e. makes note of the

sequence of the buttons, it’s on time and off time. Once you are done with the
tone, you can push the Interrupt Button.

5. As soon as the Arduino enters Interrupt Mode, all the previously pressed
tones are played back through the Piezo Buzzer.

6. During normal tone playback i.e. when the buttons are being pressed, the
LED on pin 13 stays ON. During repeat mode, it stays OFF.

CONCEPT:

1. The main concept of the Arduino based Piano is very simple. Here, we had
used Push Buttons for Recording Purpose.

2. Actually, I have made Interrupt Button as the Stop stage to play the recorded
tone.

3. The main aim of this project is to Play the tone according to the user’s
decision at anywhere, and anytime.
PROGRAM:

int val=0;
int buzzer = 10;
unsigned long on_time=0;
unsigned long off_time=0;
unsigned long button_ontime[20];
unsigned long button_offtime[20];
int button_seq[20];
int button1=3;
int button2=4;
int button3=5;
int button4=6;
int button5=7;
int button6=8;
int button7=9;
int button8=10;
int frequency[] = {262, 294, 330, 349, 392, 440, 494};

int buttonPin = 2;
int previousState = HIGH;
unsigned int previousPress;
volatile int buttonFlag;
int buttonDebounce = 20;
int path=1;
int i=0;
int led=13;
void playback (void);
void setup()
{
Serial.begin(9600);
pinMode(buzzer,OUTPUT);
pinMode(led,OUTPUT);
///////////////
pinMode(button1,INPUT_PULLUP);
pinMode(button2,INPUT_PULLUP);
pinMode(button3,INPUT_PULLUP);
pinMode(button4,INPUT_PULLUP);
pinMode(button5,INPUT_PULLUP);
pinMode(button6,INPUT_PULLUP);
pinMode(button7,INPUT_PULLUP);
pinMode(button8,INPUT_PULLUP);
pinMode(buttonPin,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), button_ISR, CHANGE);
analogWrite(buzzer,0);
digitalWrite(led,HIGH);
}
void loop()
{
if(path==0)
{
Serial.println("playback");
playback();
}
if((millis() - previousPress) > buttonDebounce && buttonFlag)
{
previousPress = millis();
if(digitalRead(buttonPin) == LOW && previousState == HIGH)
{
path =! path;
previousState = LOW;
}
else if(digitalRead(buttonPin) == HIGH && previousState == LOW)
{
previousState = HIGH;
}
buttonFlag = 0;
}

if(digitalRead(button1)==LOW)
{
analogWrite(buzzer,frequency[0]);
on_time=millis();
if(i>0)
{
button_offtime[i-1]=on_time-off_time;
}
while(digitalRead(button1)==LOW);
if(path==1)
{
off_time=millis();
button_ontime[i]=(off_time-on_time);
button_seq[i]=0;
i++;
Serial.println("button 1 stored");
}
}

else if(digitalRead(button2)==LOW)
{
analogWrite(buzzer,frequency[1]);
on_time=millis();
if(i!=0)
button_offtime[i-1]=on_time-off_time;
while(digitalRead(button2)==LOW);
if(path==1)
{
off_time=millis();
button_ontime[i]=(off_time-on_time);
button_seq[i]=1;
i++;
Serial.println("button 2 stored");
}
}

else if(digitalRead(button3)==LOW)
{
analogWrite(buzzer,frequency[2]);
on_time=millis();
if(i!=0)
button_offtime[i-1]=on_time-off_time;
while(digitalRead(button3)==LOW);
if(path==1)
{
off_time=millis();
button_ontime[i]=(off_time-on_time);
button_seq[i]=2;
i++;
Serial.println("button 3 stored");
}
}

else if(digitalRead(button4)==LOW)
{
analogWrite(buzzer,frequency[3]);
on_time=millis();
if(i!=0)
button_offtime[i-1]=on_time-off_time;
while(digitalRead(button4)==LOW);
if(path==1)
{
off_time=millis();
button_ontime[i]=(off_time-on_time);
button_seq[i]=3;
i++;
Serial.println("button 4 stored");
}
}

else if(digitalRead(button5)==LOW)
{
analogWrite(buzzer,frequency[4]);
on_time=millis();
if(i!=0)
button_offtime[i-1]=on_time-off_time;
while(digitalRead(button5)==LOW);
if(path==1)
{
off_time=millis();
button_ontime[i]=(off_time-on_time);
button_seq[i]=4;
i++;
Serial.println("button 5 stored");
}
}

else if(digitalRead(button6)==LOW)
{
analogWrite(buzzer,frequency[5]);
on_time=millis();
if(i!=0)
button_offtime[i-1]=on_time-off_time;
while(digitalRead(button6)==LOW);
if(path==1)
{
off_time=millis();
button_ontime[i]=(off_time-on_time);
button_seq[i]=5;
i++;
Serial.println("button 6 stored");
}
}

else if(digitalRead(button7)==LOW)
{
analogWrite(buzzer,frequency[6]);
on_time=millis();
if(i!=0)
button_offtime[i-1]=on_time-off_time;
while(digitalRead(button7)==LOW);
if(path==1)
{
off_time=millis();
button_ontime[i]=(off_time-on_time);
button_seq[i]=6;
i++;
Serial.println("button 7 stored");
}
}

analogWrite(buzzer,0);
}
void playback (void)
{
digitalWrite(led,LOW);
for(int j=0;j<i;j++)
{
analogWrite(buzzer,frequency[button_seq[j]]);
delay(button_ontime[j]);
analogWrite(buzzer,0);
delay(button_offtime[j]);
}
i=0;
off_time=0;
on_time=0;
path=1;
digitalWrite(led,HIGH);
}
void button_ISR()
{
buttonFlag = 1;
}
CHAPTER 5

RESULT AND DISCUSSION

FIGURE 5.1 PROGRAMMING PART

FIGURE 5.2 ON STATE CONDITIONS


FIGURE 5.3 RUNNING MODE

FIGURE 5.4 END MODE


CHAPTER 6CONCLUSION

This Project of “ARDUINO BASED PIANO PIEZO-BUZZER” is


cost-effective, practical, light-weight and an simple DIY project where we can
play Piano anywhere at anytime for use. Also, we can create an mini Piano by
using Arduino(UNO), push buttons, and an buzzer. This project can be helpful in
understanding the sound capabilities of Arduino. This doesn’t replicate the
original Piano but gives you an idea on how to implement a smaller version than
on your own capabilities. Although, we haven’t used the tone () function, you
can implement the same thing using that function for the more accurate results.

6.1 FUTURE SCOPE:

From this project, we can develop an mini-musical instrument the so


called Piano by using Arduino and Buzzer. It will be an emergence in the field of
Automation where the systems can do the main work without the intervention of
Human-Beings. It will be an cost-effective, light-weight component so that we
can transport it anywhere and use it at anytime i.e., Transportation is easy because
it is made up of light weight materials. In the future, Instead of people to the
musical classes they will use this technology and they will improve their musical
skills. It may leads to some replicas of the other musical instruments discovery
with this technology. It is not that much tough to play and also it only consists of
seven buttons instead of many buttons for their functioning and also it will contain
an new feature called Interruption, the stage in which it plays the recorded tones.
CHAPTER 7

REFERNCES:

1. "buzzer - definition of buzzer by The Free Dictionary". Retrieved 22


May 2015.

2. "The History of the Doorbell 1800doorbell.com". www.1800doorbell.com.


Retrieved 2015-07-12.

3. "Piezo Systems: History of Piezoelectricity". www.piezo.com.


Retrieved 2015-07-12.

4. http://www.puiaudio.com/resources-white-papers-helmholtz.aspx

5. "LilyPad Arduino Main Board". www.arduino.cc. Retrieved 20


February 2018.

6. "Arduino Blog – A new era for Arduino begins today". Arduino Blog.
Retrieved 19 Jan 2018.

Das könnte Ihnen auch gefallen