Bird
0
0
Arduinoprogramming~20 mins

tone() function for frequency generation in Arduino - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tone Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output sound frequency?
Consider this Arduino code snippet using the tone() function. What frequency will the buzzer produce?
Arduino
void setup() {
  tone(8, 1000);
}

void loop() {
  // no code here
}
ANo sound (tone not started)
B500 Hz tone on pin 8
C1000 Hz tone on pin 8
DTone on pin 8 but frequency unknown
Attempts:
2 left
💡 Hint
The second parameter of tone() is the frequency in Hertz.
Predict Output
intermediate
1:30remaining
What happens when duration is specified?
What will happen when this Arduino code runs?
Arduino
void setup() {
  tone(9, 440, 500);
}

void loop() {
  // no code here
}
APin 9 outputs a continuous 440 Hz tone
BPin 9 outputs a 500 Hz tone for 440 milliseconds
CNo tone is produced because duration is too short
DPin 9 outputs a 440 Hz tone for 500 milliseconds, then stops
Attempts:
2 left
💡 Hint
The third parameter of tone() is the duration in milliseconds.
🔧 Debug
advanced
2:00remaining
Why does this code produce no sound?
This Arduino code is supposed to play a 1000 Hz tone on pin 7, but no sound is heard. What is the problem?
Arduino
void setup() {
  tone(7);
}

void loop() {
  // no code here
}
AMissing frequency parameter in tone() call
Btone() requires a duration parameter
Ctone() cannot be called in setup()
DPin 7 is not a PWM pin
Attempts:
2 left
💡 Hint
Check the parameters required by tone().
🧠 Conceptual
advanced
2:00remaining
What happens if tone() is called twice on the same pin?
If you call tone(6, 500); and then immediately call tone(6, 1000);, what will happen?
ABoth tones play simultaneously on pin 6
BThe tone changes to 1000 Hz immediately on pin 6
CThe first tone continues and the second call is ignored
DThe Arduino will crash due to conflict
Attempts:
2 left
💡 Hint
Calling tone() on the same pin replaces the previous tone.
Predict Output
expert
2:30remaining
How many tones are playing after this code runs?
Given this Arduino code, how many pins are producing sound simultaneously?
Arduino
void setup() {
  tone(3, 400);
  tone(5, 600);
  tone(3, 800);
  noTone(5);
}

void loop() {
  // no code here
}
AOne tone on pin 3 at 800 Hz
BTwo tones: pin 3 at 400 Hz and pin 5 at 600 Hz
COne tone on pin 5 at 600 Hz
DNo tones playing
Attempts:
2 left
💡 Hint
Remember that calling tone() on the same pin replaces the previous tone, and noTone() stops the tone on that pin.