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

Siren Toggle with Code Car

 
 

Create separate buttons for each siren light so that you can control how they toggle on and 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: A Pattern of Statements

This lesson takes one step up from your previous 'if-else' statements! If you showed this program to someone who had never seen block code before, they'd be amazed (and maybe confused). You should be seeing the patterns in the programs at this point and understanding that, although there are lots of syntax marks, line breaks, and strangely typed words in the code, you're really looking at a simple 'if' statement, repeated twice. If you played around with the challenges and the code, you probably saw that the 'if' statements aren't related to each other; that is, you can delete one 'if-else' statement and the code still works. Continue trying to see the patterns in a program when you first look through it. You might even notice that you can skim over some of the details of the example code at this point and quickly get the 'general idea' of the program just by looking at it.

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 right way to string together four if and else statements?




What is the repeated pattern in this program?