Blink both of the siren lights to learn about combining code commands. Get creative with your light patterns!
The code below already works and is ready to upload! Upload the code to Code Car and see what happens. Then, you'll 'take apart' the code to learn what each piece of the program does.
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!
How many can you complete? Change the code according to the challenges below. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!
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: Using Speed as a Tool
You already know that computers can run code really quickly. So quickly that your eyes can't even see it! If you want to make two things appear to happen at the exact same time, that's pretty easy to do on Code Car- just type the code commands one line after another with no delay in between.
New Concept: Finding Patterns
If you were successful in both challenges on this program, you probably figured out that there is a pattern that you can follow to complete a task. In this program, for example, the pattern for adding a new LED light is:
1. Add a pinMode command for that light.
2. Add a digitalWrite( , HIGH); command next to the other digitalWrite( ,HIGH); commands.
3. Add a digitalwrite( ,LOW); command next to the other digitalWrite( ,LOW); commands.
Once you know the pattern, you can imagine how you'd add any number of LED lights to the program! Don't be spooked as programs get larger- there are almost always patterns repeating throughout.
QuizIf you're having trouble, try to run an experimental program or look at the example code to help you find the answer.
To make two things appear to happen at the same time, you need to ___________.
If you don't type everything perfectly in a code comment or you forget to type one, what will happen?