Complete the code to play a 440 Hz tone on pin 8.
tone(8, [1]);
The tone() function needs the pin number and the frequency in hertz. 440 Hz is the frequency for the A note.
Complete the code to stop the tone on pin 8.
tone([1], 440); // some delay here noTone([1]);
tone() and noTone().The noTone() function stops the tone on the same pin where tone() was called. Here, pin 8 is used.
Fix the error in the code to play a 1000 Hz tone for 500 milliseconds on pin 6.
tone(6, [1], 500);
The second argument of tone() is the frequency in hertz. 1000 Hz is the correct frequency to play.
Fill both blanks to play a 523 Hz tone on pin 5 for 1000 milliseconds.
tone([1], [2], 1000);
The first blank is the pin number 5, and the second blank is the frequency 523 Hz (note C5).
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'.
const int notes[] = { [1] };
int freq = notes[[2]];
tone(3, [3], 300);The array contains frequencies for notes C, D, E (262, 294, 330). Index 2 is the third note 'E'. The variable freq holds the frequency to play.
