Complete the code to play a sound using the buzzer.
tone(8, [1]);
The tone() function needs a frequency value to play a sound. 440 Hz is the frequency for the note A.
Complete the code to stop the sound from the buzzer.
noTone([1]);The buzzer is connected to pin 8, so noTone(8); stops the sound on that pin.
Fix the error in the code to play a 1-second beep.
tone(8, 1000); delay([1]); noTone(8);
The delay should be 1000 milliseconds to play the beep for 1 second.
Fill both blanks to create a dictionary of notes and their frequencies.
int notes[] = [1]; int frequencies[] = [2];
In Arduino C++, arrays use curly braces {} to list values. The first array is notes, the second is frequencies.
Fill all three blanks to play each note for 500 milliseconds.
for (int i = 0; i < [1]; i++) { tone(8, [2][i]); delay([3]); noTone(8); }
The loop runs 4 times for 4 notes. The frequencies array holds the sound frequencies. Delay is 500 ms for each note.
