Break the Silence - Piezo Speaker!
by sahana_sasikumar in Circuits > Arduino
113 Views, 0 Favorites, 0 Comments
Break the Silence - Piezo Speaker!
Hey guys! Want to take control of a speaker? Well here you've got the perfect tutorial on how to do so! In this instructable, I will guide you through the simple steps needed to turn a buzzer on when a button is clicked an turn it back off when it is clicked again.
Step 1: Downloading the Arduino IDE
Download and Install the Arduino IDE (Interactive Development Environment) using the link below:
https://www.arduino.cc/en/Main/Software
Choose and save the version that best suits your operating system and configuration.
​Step 2: Hardware Materials
- Arduino board
- 1 breadboard
- 2 male-male jumper wires
- 1 Piezo speaker
Step 3: Building the Hardware
Add the piezo speaker to the breadboard. Connect the short leg of the piezo speaker to Ground, long leg to pin 9 with jumper wires and resistors shown in the diagram.
Step 4: Downloading and Running the Program
Download the attached arduino program to your laptop. Connect the arduino to your laptop, and run the program. You should have a buzzing sound that goes on and off with 1 second intervals.
Downloads
Step 5: Understanding the Program
Piezo has two methods:
- tone(piezoPinNumber, delay) which makes piezo to buzz
- noTone(piezoPinNumber) which makes piezo to switch off
In setup method, pin 9 is declared as output.
In loop method, the tone method is called causing the piezo speaker to buzz, for 1 second. Then the noTone method is called causing the piezo speaker to turn off, for 1 second. Delay of 1 second is used to ensure the buzz doesn't turn ona nd off too quickly.