It is Practical For Many Projects Including LED Clocks. We actually expect some visual, auditory feel along with tactile feel. Normally, we create sound on Arduino in complex way as the sounds has lot of pitches. But here, we just need a simple sound, so the circuit and code is easy and ready to be adapted inside other projects. Here is How to Make Beep Sound in Arduino Project Upon Push Button Press.
How To Make Beep Sound in Arduino Project Upon Push Button Press
In this project, we will make a circuit which will play a sound using a buzzer and an LED which sound and as example of a complex project, it will light up LED when a button is pressed. For this project, we need :
Arduino UNO or similar board
Piezo Buzzer – One
LED – One
220 Ohm Resistor – One
10K Ohm Resistor – One
Pushbutton – One
Breadboard – One
Jumper Wires – Few
---
The circuit itself quite simple circuit to set up. Be careful with the positive and negative poles of piezo buzzer :
Arduino has documentation on Tone :
1 | https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/ |
And slightly complex example of simple keyboard using the tone()
function :
1 | Simple keyboard using the tone() function |
For our need, here is the code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | int buzzerPin = 9; int buttonPin = 7; int ledPin = 6; const int toneFreq = 523; void setup() { pinMode(buzzerPin, OUTPUT); pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { int buttonState = digitalRead(buttonPin); if (buttonState==LOW) { digitalWrite(ledPin, HIGH); tone(buzzerPin, toneFreq); } else { digitalWrite(ledPin, LOW); noTone(buzzerPin); } } |
Some years back, I kept the schematic and code (as text file) inside a directory for future in need of my project. I actually not thought of sharing it at that time. I am not sure who actually written the code. Although a small snippet is not huge matter, yet it is correct to give the reference of the person who gave some time behind it to find out. Which unfortunately I can not do now.
Tagged With Arduino beep , how to make a button make a sound on arduino , how to make buzzers go on once button is pressed in arduino , button pressed make sound arduino , https://thecustomizewindows com/2018/06/make-beep-sound-in-arduino-project-when-a-push-button-is-pressed/ , How to make Arduino beep , how to make a buzzer beep when button is pushed arduino , something that make sound when press button , arduino button Klick beep , arduino beep sound