Bug Hunt! Test your Troubleshooting.

Here’s how Bug Hunts work:

We’ve taken the example code from the last project and inserted errors into it. These errors might be spelling problems, syntax, or we might have changed up how the program works altogether!

The goal of the Bug Hunt is to find and fix the errors so that when you upload the code, it runs just like the example code did on the project page.

Try these steps in order to solve a Bug Hunt:

1) Look over the code closely first, looking for anything that is out of place. We recommend you do this first to build up your ‘bug hunting instincts’.

2) Press ‘Upload the Code’ with your board plugged in and the circuit built. The code won’t work, but it will show you the errors that the computer found - these will pop up in a box just below the code editor. These clues are sometimes vague or confusing, but they may help you find out where the problem is.

3) Get out the purple and blue cards from your kit. Find each purple card that references a code concept you see in the buggy program. Compare what the purple card says about each code concept to what you see on the screen. Compare what the blue cards say about how to use the component to how the components are used in the buggy program. Are they the same? What’s different? That may be the bug!

After you’ve fixed the bug and the code is working again, hit ‘Restore’ so you can see the code how it was before you fixed it. Is the bug obvious to you now? Reviewing like this will make it easier to find bugs in future programs!

Get stuck? Click on ‘Need a Hint?’ below. It will provide a clue about what’s wrong in this program.

// Blink 2 LEDs with alternating tones like a police siren void setup(){ pinMode(2,OUTPUT); //LED light pinMode(6,OUTPUT); //LED light pinMode(A5,OUTPUT); //Speaker } void loop(){ digitalWrite(2,HIGH); //Turn on LED 2 digitalWrite(6,LOW); //Turn off LED 6 //tone(A5,500); //Play a tone of 500 hertz delay(1000); //Wait 1000 milliseconds (one second) digitalWrite(2,LOW); //Turn off the first LED digitalWrite(6,HIGH); //Turn on the second LED tone(A5,1500); //Play a tone of 1500 hertz delay(1000); //Wait 1000 milliseconds before restarting the loop } //(c)2019 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 



Need a hint? Click here.