You'll want to warm up your boosters or slow down your speed gradually when taking off and landing the Code Rocket. Learn how to gradually increase the power sent to your booster LEDs.
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: analogWrite
This project is the first time you’ve seen that you can send signals besides ‘on’ and ‘off’ to an LED. Note that this capability isn’t available on all of Code Rocket’s LEDs, just LEDs 3, 5, 6, 9, and 10. analogWrite has a range from 0 brightness to 255 brightness, and 255 brightness looks the same as digitalWrite(pin,HIGH); would look.
Real Life Example: Plain light switch versus a dimmer switch
A typical light switch has two positions: on or off. When a light is triggered by a switch like this, it turns on 100% power. A dimmer switch, on the other hand, has a range of values it can send to a light. The dimmer switch is like what is happening with the analogWrite command in this program.
New Concept: Limited looping
Up to this point, there have been two ‘loops’ that run in each program. The void setup is a ‘one time loop’. It runs once when the board is powered on. The void loop is continuous, running forever or until you remove power from the board. Now with the ‘for’ loop, you have control over how many times an action occurs.
1. What are the four parts of a 'for' loop, in order of how they're typed? Hint: Use your purple cards!
2. Which pins can you use with analogWrite on Code Rocket? Hint: It's in the New Concepts section!