This is a handout for a workshop at the Milton Keynes Raspberry Jam on 10 November 2018. Code for the workshop is on Github.
In this session, you'll use a Raspberry Pi to program a Micro:bit, and the Micro:bit will control a NeoPixel strip and make it a one-dimensional firework.
Find the "Start" menu → Programming → mu
Once you've opened Mu, press the Mode button and press "BBC micro:bit"
Type this program into the Mu editor. It will do the animation for a firework launching.
Note that Python is really picky about
When you've typed it in, press "Save" button to save your file then press the "Flash" button to put the program on the Microbit.
When you press the A button on the Microbit, you should see a little light shoot along the strip.
Pressing the button is OK, but let's make the firework launch if you shake the Microbit.
Make the changes indicated to your program. You don't need to type the '# Add this line' comments: that's just to show you what to do.
Again, save and flash the program. Now try shaking the Microbit and see if it launches a firework.
Now to make the firework explode at the top!
Again, save and flash your program. You should now have explosions!
What you've got is OK, but let's add some animation to the explosion. Let's make it start small and rapidly grow, and then fade over a bit of time.
Again, save and flash the program. Cool animation!
Always having the same colour explosion is a bit boring. Let's make every explosion a different colour.
Again, save and flash the program. Even cooler animation!
The animation's a bit slow. We can speed things up by only updating the pixels that change, rather than all of them.
The Microbit has a small display. Let's use that to show the firework is ready.
The Micro:bit has a radio. Let's use that to make one firework (sometimes) set off another firework.