Bird
0
0
Arduinoprogramming~15 mins

noTone() to stop sound in Arduino - Mini Project: Build & Apply

Choose your learning style9 modes available
Using noTone() to Stop Sound on Arduino
📖 Scenario: You have a small buzzer connected to your Arduino. You want to play a sound for a short time and then stop it.
🎯 Goal: Build a simple Arduino program that plays a tone on a buzzer and then stops the sound using noTone().
📋 What You'll Learn
Create a variable for the buzzer pin number
Set the buzzer pin as an output
Use tone() to play a sound on the buzzer
Use noTone() to stop the sound
💡 Why This Matters
🌍 Real World
Stopping sounds on devices like alarms, timers, or notifications is common in electronics projects.
💼 Career
Understanding how to control hardware like buzzers is useful for embedded systems and IoT jobs.
Progress0 / 4 steps
1
Set up the buzzer pin
Create an integer variable called buzzerPin and set it to 8. Then, in the setup() function, use pinMode(buzzerPin, OUTPUT); to set the buzzer pin as an output.
Arduino
Hint

Remember to declare buzzerPin as an integer and set it to 8. Then use pinMode inside setup().

2
Play a tone on the buzzer
In the loop() function, use tone(buzzerPin, 1000); to play a 1000 Hz tone on the buzzer.
Arduino
Hint

Use the tone() function with buzzerPin and frequency 1000.

3
Stop the tone using noTone()
After playing the tone, use noTone(buzzerPin); to stop the sound. Add a delay of 1000 milliseconds before stopping the tone.
Arduino
Hint

Use delay(1000); to wait one second, then call noTone(buzzerPin); to stop the buzzer.

4
Print a message when the tone stops
After stopping the tone with noTone(buzzerPin);, add Serial.begin(9600); in setup() and use Serial.println("Tone stopped"); in loop() to print the message.
Arduino
Hint

Initialize serial communication in setup() and print the message after stopping the tone in loop().