/* Beep 3 rising tones. Use this as starting point for songs and sound effects! */
void setup(){
pinMode(A5,OUTPUT); //Set pin A5 to receive power
}
void loop(){
tone(A5,200); //Send a tone of 200 hertz (hz) to the speaker
delay(500); //Delay 500 milliseconds (half a second) with the tone playing
tone(A5,400); //Play a tone of 400 hertz
delay(500); //Delay 500 milliseconds
tone(A5,800); //Play a tone of 800 hertz
delay(500); //Delay 500 ms
noTone(A5); //Turn off any tones playing
delay(3000); //Delay 3 seconds with no sound before the loop starts over
}
// (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
It looks like your computer isn't set up to code yet.
Success!
Compile errors:
Serial port monitor:
Input:
Walkthrough Video
Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!
Challenges
Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!