Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_8 analogWrite Motor Strength
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_7 analogWrite Brightness
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_6_1 Alternate LED Blinks Bug
Bug Hunt! Test your Troubleshooting.
Prefer listening over reading? Click the play button in the audio bar.
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) Check your code references, especially for the functions that have turned red when you hit “Upload”. Compare the syntax of your reference book to the syntax in your code editor here.
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.
Check the capitalization of the words. Most code follows very strict rules about which words or letters are capitalized, and the computer won't recognize a command that isn't capitalized correctly!
Most commonly used keywords in code get highlighted to a new color when they are entered correctly. You can scan over the code with your eyes to see if anything sticks out that isn't highlighted.
1_6 Alternate LED Blinks
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_5 Serial Print a Message
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_4_1 Play 3 Tones Bug Hunt
Bug Hunt! Test your Troubleshooting.
Prefer listening over reading? Click the play button in the audio bar.
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) Check your code references, especially for the functions that have turned red when you hit “Upload”. Compare the syntax of your reference book to the syntax in your code editor here.
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.
Some of the syntax in code looks very similar, like the bracket [ ],the curly brace { }, and the parentheses ( ). The arguments of a function should be surrounded by parentheses!
1_4 Beep 3 Tones on the Speaker
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_3 Blink Two Synced LEDs
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_3_1 Blink 2 Synced LEDs Bug Hunt
Bug Hunt! Test your Troubleshooting.
Prefer listening over reading? Click the play button in the audio bar.
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) Check your code references, especially for the functions that have turned red when you hit “Upload”. Compare the syntax of your reference book to the syntax in your code editor here.
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.
Functions end with a semicolon ( ; ). If one is missing, you'll have problems!
1_2 Buzz the Motor
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_1 Single Beep the Speaker
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.
1_0_1 Blink Bug Hunt
Blink Bug Hunt! Test your Troubleshooting.
Prefer listening over reading? Click the play button in the audio bar.
Here’s how Bug Hunts work:
We’ve taken the example code from the last project (in this case, Blink) 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) Check your code references, especially for the functions that have turned red when you hit “Upload”. Compare the syntax of your reference book to the syntax in your code editor here.
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.
Check the capitalization of the words. Most code follows very strict rules about which words or letters are capitalized, and the computer won't recognize a command that isn't capitalized correctly!
1_0 Blink an LED Light
Code
The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port with the cable and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.