5. Case 05: Magic Power Indicator¶
To create a magic wand that can indicate the level of the magic power.
After recharging the magic wand, this is the only equipment left in his team. Xiao En decides to make a power indicator to save the energy as much as he can.
Click “Advanced” in the MakeCode drawer to see more choices.
We need to add a package for programming, . Click “Extensions” in the bottom of the drawer and search with “magicwand” in the dialogue box to download it. (Kindly note this package is still in the verifying process and pls search with “https://github.com/elecfreaks/pxt-magicwand “ before it’s ready)
Note: If you met a tip indicating that the codebase will be deleted due to incompatibility, you may continue as the tips say or build a new project in the menu.
Choose the variables in the MakeCode drawer and write the letter “i” in the dialogue box to confirm it.
Initialize the Neopixel strips to connect to P8 with 8 beads and set the variable to 7 and the strip in bule in the on start brick.
While button in P2 being pressed, programme to set the pixel “i” in red, refresh the strip and set “i”=”i”-1.
After powering on, the strip light on in blue, while pressing the button, the last LED in blue turns to red.