When the big moment comes for takeoff, all systems must be tested and everything has to go just right! Program the perfect countdown sequence to ensure a successful liftoff.
The code in the editor below already works. Just plug in your Code Rocket and press upload to see what it does! Tinker with it and make changes to see what each line of code controls.
New Concept: Logical planning
When working on a program like this that has a sequence of steps that must be followed, it can be easy to get a little lost. There are two approaches that will help you think through the logic of your program before you write it.
1) Code and Upload (often)! Once you have the bare minimum of a program - void setup(){} and void loop(){} - you can upload your code to the Code Rocket and see what it does. You don’t need to complete the entire program before trying to upload it. If you upload a little bit of code, then add more, then upload again, you might find something that was wrong much earlier than you otherwise would have.
2) Screen-free planning. You can write down the steps you want Code Rocket to follow, draw diagrams, or write a story of how you want Code Rocket to work before you ever touch the keyboard. Sometimes the syntax and challenges of writing code get in the way of the original idea. Rather than focusing on what exactly the code will look like, first think through the steps and make a guide for yourself. The ‘story’ for this example program might be:
“Start with all of the LED circle lights on. Each second, turn one off and play a tone that gets lower. After all of the circle LEDs are off, turn on the booster LED lights for takeoff. Make some kind of sound effect like the rocket’s engines are roaring as it lifts off.”
This short outline provides the basics of the programs without getting too specific. Then you can use the Code and Upload (often!) technique to turn the outline into a program.