Speaker Rising & Falling Tone Bug Hunt! Test your Troubleshooting.

A simple reversed character is going to cause all kinds of buggy problems in this program. Can you find it before you upload? If not, your ears will definitely tell you something is wrong!

//Buggy: Create a rising and falling siren on the Speaker void setup(){ pinMode(10,OUTPUT); //Set the speaker as an OUTPUT } void loop(){ for(int i=40; i>800; i++){ //start at 40 hertz and play a new tone up to 800 hertz tone(10,i); //play the tone that is equal to the variable 'i' delay(3); //delay 3 milliseconds before starting the 'for' loop again } //The second 'for' loop only runs after the first 'for' loop has completed for(int i=800; i>40; i--){ //start at 800 hertz and play a new tone down to 40 hertz tone(10,i); //play the tone that is equal to the variable 'i' delay(3); //delay 3 milliseconds before starting the 'for' loop again } } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 



Need a hint? Click here.