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. 

/* * Turn on both siren lights at once with a single button press. */ void setup(){ pinMode(5, OUTPUT); // Blue siren light pinMode(6, OUTPUT); // Red siren light pinMode(9, INPUT_PULLUP); //Button to activate the siren lights } void loop(){ //if the 9 pushbutton is pressed, turn the 5 and 6 LEDs on if (digitalRead(9) == LOW) { //the code between the braces is the 'action' digitalWrite(5,HIGH); } digitalWrite(6,HIGH); else { digitalWrite(5,LOW); //otherwise, turn the 5 LED off digitalWrite(6,LOW); //also turn LED 6 off } } //This curly brace ends the loop // (c) 2022 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 



Need a hint? Click here.