Blink a Rocket Headlight

Add some action to your coding loop with a blinking LED light.

Code

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.

Walkthrough Videos

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!


Challenges

Can you complete the challenge? Does this challenge give you any more ideas to try out? Once you've updated the code, make sure to hit the Upload button!

Concepts

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: Loops

Computers are great at doing things over, and over, and over, and over again. That’s what happens inside your void loop() function in this program. The computer reads your program from top to bottom, so it reads line 8 before line 9. However, it’s reading really fast, so you’ll usually have to add in some delay to make sure you can see how your program is working.

As you program more, you’ll get better at imagining which line of code is running as you watch your program work on Code Rocket. You might even start to think of the program more as a ‘circle’ than a single sheet of code.

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. If you let the example code run, how many times will the code loop?