Bug Hunt! Test your Troubleshooting.

You may have already run into some errors in modifying or writing your own code. Don't worry, studies have shown that almost half of all code 'compiles' result in an error! 

The code below has some errors sprinkled in it. Before you run the code, read through it and look for the errors, called bugs. Can you find them? Try to fix each one and then see if the code runs. 

/* * Press button 9 to honk the horn on Code Car */ void setup(){ pinMode(9,INPUT_PULLUP); //Button to activate the horn pinMode(2,OUTPUT); //Horn on the Code Car } void loop(){ else{ // an else statement runs when the 'if' condition isn't true noTone(2); //otherwise, silence the horn. } //if the pushbutton is pressed, start playing a tone if (digitalRead(9) ==LOW) { //if the button is pressed tone(2,250); //the code between the braces is the 'action' } } // (c) 2022 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 



Need a hint? Click here.