Challenge - 5 Problems
Tone Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1: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
}Attempts:
2 left
💡 Hint
The second parameter of
tone() is the frequency in Hertz.✗ Incorrect
The
tone() function starts a square wave of the given frequency on the specified pin. Here, 1000 means 1000 Hz.❓ Predict Output
intermediate1: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
}Attempts:
2 left
💡 Hint
The third parameter of
tone() is the duration in milliseconds.✗ Incorrect
The
tone() function with three parameters plays the tone for the specified duration then stops automatically.🔧 Debug
advanced2: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
}Attempts:
2 left
💡 Hint
Check the parameters required by
tone().✗ Incorrect
The
tone() function requires at least two parameters: pin and frequency. Calling it with only the pin does nothing.🧠 Conceptual
advanced2: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?Attempts:
2 left
💡 Hint
Calling
tone() on the same pin replaces the previous tone.✗ Incorrect
The second
tone() call stops the first tone and starts the new frequency on the same pin.❓ Predict Output
expert2: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
}Attempts:
2 left
💡 Hint
Remember that calling
tone() on the same pin replaces the previous tone, and noTone() stops the tone on that pin.✗ Incorrect
The first
tone(3, 400); starts 400 Hz on pin 3. Then tone(5, 600); starts 600 Hz on pin 5. Next, tone(3, 800); replaces the 400 Hz tone on pin 3 with 800 Hz. Finally, noTone(5); stops the tone on pin 5. So only pin 3 plays an 800 Hz tone.