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!
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.
HOC: Finding Patterns
In this lesson, you'll start to see some repetition of code commands. It's a good idea to look for patterns in programs, so that you can start to make broad connections about how code is working without getting too caught up in the details. In this case, you'll use the exact same commands to control two different LED lights on Code Car, turning them on, then turning them off. Once you recognize the pattern that you need for each LED, it's simple to add more LEDs for a light show!
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?