Coding Fireworks!
Finally - it’s the time of year we all look forward to, the first BIG longgg weekend! Let’s celebrate with some fireworks. We’ll use the leds on our micro:bit (m:b) for the lights and Makecode to get the party started!
These fireworks are an example of an animation. It works on the same principle as a flip book where flipping the pages “animate” drawings. Our animation sees a group of lit LED images changing quickly. To plan your animation, use the LED planning Grid found mid way down this Classroom resources page. Plotting which LEDs will be lit in advance will save some valuable time when it comes to coding!
Now for the code! I’ve used on button A pressed to “light” my fireworks, but you may wish to level up the code using m:bs built in sensor to set the fireworks off when the m:b senses it’s dark enough out! The code for a night light from MakeIt CodeIt may be just the inspiration you need!
I don’t like long strings of code. It’s hard for others to read and understand. Coders will often break their code into more manageable pieces so it’s easier to debug and comprehend. I used Functions for these reasons.
The LEDs on the micro:bit can be coded to turn on all together, in a pattern, or even one at a time. By checking out my code, you can see I “plotted” or turned on LEDs at certain points, then toggled them “off” - in this case. I also changed the brightness setting to simulate the sparks burning out.
Use this image to get the correct coordinates for plotting and toggling your LEDs.
You may wish to learn more about micro:bits, animations and coding! Check out some awesome asynchronous courses offered by Micro:bit. Be sure to look at the resources page as well for good classroom materials.
As always - I love checking out you and your student creations! Please, please share them on social!
About the Author:
Barb Seaton is brought to you by the letter M - Math, Micro:bit, Makey Makey and Minecraft! A professional learning associate with Fair Chance Learning, previous educator and Provincial Mathematics Professional Learning Facilitator, Barb offers a wealth of knowledge and expertise in integrating new technology with math curriculum. Barb works with District School Boards across Canada delivering professional learning on computational thinking, coding and integrating programmable devices. Catch Barb on twitter @barb_seaton