// Copyright 2007, Sandeep Gangadharan // For more free scripts go to http://www.sivamdesign.com/scripts/

Siren Lights with Code Car

 
 

Hold down a single button to turn on both sirens of Code Car. Release the buttons to turn them off. 

Code

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.

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

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!



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: Growing Your 'if' Statements

This lesson helps you build on the powers of the 'if' statement. If you completed the challenges, you now see that the 'if' statement can be used to combine a number of commands and control multiple outputs with a single button press. As the number of lines in your programs grows, try to keep looking for patterns or 'reversals' of the concepts you're using. For example, the challenge of keeping all of the lights off when the button was pressed has more to do with patterns and code structure than it does with any new code concept. 

Quiz

If you're having trouble, try to run an experimental program or look at the example code to help you find the answer.

What is the maximum number of code commands you can run inside an 'if' statement?




An else statement only runs when_____________________