Random Rocket LEDs 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. 

//Buggy: Turn on and off the LEDs in the LED ring randomly with random delays void setup(){ pinMode(3,OUTPUT); //Set each LED as an OUTPUT pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); } void loop(){ digitalWrite(random(7,3),HIGH); //Select LED 3,4,5, or 6 and turn it on delay(random(100,300)); //Delay for 100 - 299 milliseconds digitalWrite(random(3,7),LOW); //Select LED 3,4,5, or 6 and turn it off delay(random(100,300)); //Delay for 100 - 299 milliseconds } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 



Need a hint? Click here.