Bird
0
0
Arduinoprogramming~10 mins

tone() function for frequency generation in Arduino - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to play a 440 Hz tone on pin 8.

Arduino
tone(8, [1]);
Drag options to blanks, or click blank then click option'
AdigitalWrite
BpinMode
C440
Ddelay
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function name instead of a frequency number.
Confusing pin number with frequency.
2fill in blank
medium

Complete the code to stop the tone on pin 8.

Arduino
tone([1], 440);
// some delay here
noTone([1]);
Drag options to blanks, or click blank then click option'
A9
B7
C10
D8
Attempts:
3 left
💡 Hint
Common Mistakes
Using different pin numbers for tone() and noTone().
Using a pin number that is not connected.
3fill in blank
hard

Fix the error in the code to play a 1000 Hz tone for 500 milliseconds on pin 6.

Arduino
tone(6, [1], 500);
Drag options to blanks, or click blank then click option'
Adelay
B1000
Ctone
DpinMode
Attempts:
3 left
💡 Hint
Common Mistakes
Using function names instead of frequency numbers.
Omitting the frequency argument.
4fill in blank
hard

Fill both blanks to play a 523 Hz tone on pin 5 for 1000 milliseconds.

Arduino
tone([1], [2], 1000);
Drag options to blanks, or click blank then click option'
A5
B523
C8
D440
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up pin number and frequency.
Using wrong frequency values.
5fill in blank
hard

Fill all three blanks to create a dictionary of notes with their frequencies and play the tone for 300 ms on pin 3 for the note 'E'.

Arduino
const int notes[] = { [1] };
int freq = notes[[2]];
tone(3, [3], 300);
Drag options to blanks, or click blank then click option'
A262, 294, 330
B2
Cfreq
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong index for the note.
Passing the frequency number directly instead of the variable.