Rocket Blaster Sound Effects Bug Hunt! Test your Troubleshooting.

Sometimes its the little things in a program that can hide a mistake. Can you find this one before uploading? What would the outcome be if you did upload this buggy program?

/*Buggy: Light up the Blaster LEDs and play a sound when the corresponding button is pressed */ void setup(){ pinMode(2,OUTPUT); //Speaker pinMode(7,OUTPUT); //Blaster LED pinMode(8,OUTPUT); //Blaster LED pinMode(12,INPUT_PULLUP); //Button pinMode(11,INPUT_PULLUP); //Button } void loop(){ if(digitalRead(12)==LOW){ //if button 12 is pressed digitalWrite(8,HIGH); //turn on LED 8 tone(2,5000); //play a tone of 500 hertz on on the speaker } else if(digitalRead(11)==LOW){ //if button 11 is pressed digitalWrite(7,HIGH); //turn on LED 7 tone(2,800); //play a tone of 800 hertz on the speaker } else{ //if neither button 11 or 12 is pushed, turn off both lights and the speaker digitalWrite(7,LOW); digitalWrite(8,LOW); noTone(2); } } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 



Need a hint? Click here.