Random Rocket Lights

Even astronauts need to relax sometimes. Use the random function to create a color and light party on the Code Rocket.

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 challenges? Change the code in the editor above, then upload it to your Code Rocket and see if you got the result. Don't stop here, keep experimenting with the code!


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.

Concept: Random, continued

In this project you’ll continue to explore the random function and see that it can be dropped in place of any number or group of numbers in a program. As your code statements get more complex, you’re probably seeing the importance of paying attention to your syntax. In this program, for example, you have a random function inside a digitalWrite function, which is inside a the void loop function. Syntax can be tricky to keep up with, but it’s what allows your code to have more ‘layers’ like this program does.

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. The line of code delay(random(100,300)); means that the delay can last how long?