Button
Purpose
Today you will connect a button to control the lights.
Sandbox
Refresh yourself on what you did last time.
- Head to the microbit editor.
- Open a recent project you worked on.
- Download to a microbit.
- Tinker with the code. Change some values. Make it different.
- Download again.
Write in your sprint notes…
a couple important lines of code
Walkthrough
- Wire up a button according to this.
- Create a new project called
Button Sample. - Build this code that makes the LEDs change color every time you press the button.
- Download and test it on your LED strip.
Take a picture…
of your code.
Note: Hang on to this picture. You’ll use this again soon in the assessment.
Exercises
Three Colors
Approaching
- Push the save button on your Walkthrough code.
- Change the name to
Three Colors, and push the save button again. This gives you a new copy of your code. - Modify the code to cycle through 3 different colors.
HINT: there’s a number you need to change in on pin P1 pressed.
Write in your sprint notes…
the file name of your updated code.
Three Effects
Distinguished
- Push the save button on your previous code.
- Change the name to
Three Effects, and push the save button again. This gives you a new copy of your code. - Modify the code to cycle through these 3 different effects:
- moving rainbow
- a moving dot (or multiple dots?)
- solid color (that gets brighter and dimmer?)
HINT: look back at previous exercises you worked on.
Write in your sprint notes…
the file name of your updated code.