Blink the rocket’s blaster LEDs in unison, like if you were blasting up a piece of space debris.

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.

//Blink both of the laser blasters on Rocket void setup(){ pinMode(7,OUTPUT); //Set blaster 7 as an 'OUTPUT' pinMode(8,OUTPUT); //Set blaster 8 as an 'OUTPUT' } void loop(){ digitalWrite(7,HIGH); // turn on the #7 LED digitalWrite(8,HIGH); // turn on the #8 LED delay(1000); //delay the program for 1 second with the LEDs on digitalWrite(7,LOW); // turn off the #7 LED digitalWrite(8,LOW); // turn off the #8 LED delay(1000); //delay the program for 1 second with the LEDs off } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Watch the videos for line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!


Challenge

Can you complete the challenge? Make edits to the code and upload them to see if your code experiment works! Don't get discouraged if you don't get it at first - thing of the challenge as a puzzle to solve!

These are the new code concepts covered in this example program. To become a great coder, read through these concepts to learn new vocabulary.

New Concept: Speedy Commands

If you watch the example program run, the lights appear to turn on and off in perfect unison. They actually don’t. Your program is ‘executed’, or run, from the top of the loop to the bottom of the loop, line by line. It’s just that the processor on your Code Rocket has the ability to execute thousands of lines of code per second, so it appears that things happen simultaneously.


Quiz

If you're having trouble, try to run an experimental program or look at the example code to help you find the answer.

1. What will change if you move the delay(1000); from the last line of the loop to the first line of the loop?