Honk your horn with a button on Code Car, but this time using a variable.
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: Variables Replace Fixed Numbers
Variables are something that you interact with all the time and they're a very important concept in coding. In this lesson, you're simply replacing a fixed number with a variable. But imagine if you had written 1000 lines of code that all relied on pressing button 8, then button 8 broke! It would be so much easier to have a variable 'button' standing in for button 8 that you could change in one location and affect the rest of your code.
There are a number of different ways to use variables in coding (you'll see more ways in future lessons), but their purpose is always to make code easier to understand, simpler to change, and less repetitive.