Bird
0
0
Arduinoprogramming~10 mins

noTone() to stop sound in Arduino - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - noTone() to stop sound
Start
Call tone(pin, freq)
Sound plays on pin
Call noTone(pin)
Sound stops on pin
End
The program starts, plays a tone on a pin, then stops the sound by calling noTone on the same pin.
Execution Sample
Arduino
tone(8, 1000);  // Play 1000Hz tone on pin 8
delay(1000);      // Wait 1 second
noTone(8);        // Stop sound on pin 8
This code plays a 1000Hz sound on pin 8 for 1 second, then stops the sound.
Execution Table
StepActionPinFrequencySound StateOutput
1Call tone()81000PlayingTone starts on pin 8 at 1000Hz
2delay(1000)--PlayingSound continues for 1 second
3Call noTone()8-StoppedSound stops on pin 8
4End--StoppedNo sound playing
💡 Sound stops after noTone() is called on pin 8
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
pin 8 sound stateStoppedPlayingPlayingStoppedStopped
Key Moments - 2 Insights
Why does the sound stop after calling noTone(8)?
Because noTone(8) tells the Arduino to stop generating the sound on pin 8, as shown in step 3 of the execution_table.
What happens if noTone() is not called after tone()?
The sound will keep playing indefinitely on the pin, as seen between steps 1 and 2 where the sound state remains 'Playing'.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the sound state on pin 8 after step 2?
APlaying
BStopped
CPaused
DUndefined
💡 Hint
Check the 'Sound State' column for step 2 in the execution_table.
At which step does the sound stop playing on pin 8?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look for when 'Sound State' changes to 'Stopped' in the execution_table.
If we remove noTone(8), what would happen to the sound state after step 3?
AIt would become Stopped
BIt would remain Playing
CIt would pause
DIt would cause an error
💡 Hint
Refer to key_moments about what happens if noTone() is not called.
Concept Snapshot
tone(pin, frequency) starts sound on a pin
noTone(pin) stops sound on that pin
Use noTone() to end a tone early
Without noTone(), sound plays indefinitely
Works on Arduino digital pins
Full Transcript
This example shows how to use noTone() to stop a sound started by tone() on an Arduino pin. First, tone(8, 1000) starts a 1000Hz sound on pin 8. The program waits 1 second with delay(1000), during which the sound plays. Then noTone(8) is called to stop the sound on pin 8. The execution table tracks each step: starting the tone, waiting, stopping the tone, and ending. The variable tracker shows the sound state on pin 8 changing from stopped to playing, then back to stopped. Key moments clarify that noTone() is necessary to stop the sound, otherwise it plays forever. The quiz tests understanding of when the sound stops and what happens if noTone() is omitted. The snapshot summarizes the key points: tone() starts sound, noTone() stops it, and noTone() is needed to end the sound early.