Rather Read the Key Concept? Click Here

KEY CONCEPT: STEP-BY-STEP

To complete the challenges in this lesson, you'll have to carefully think through the logical sequence of steps the code must take in order to turn on and off the LED lights. It might be helpful to have a pencil and paper to write down the sequence of your steps before translating it into code. Remember to look for patterns that you can repeat!

 
/* * Alternate blinking the two siren lights on Code Car */ void setup() { pinMode(5,OUTPUT); //set your blue siren light as an OUTPUT pinMode(6,OUTPUT); //set your red siren light as an OUTPUT } void loop() { digitalWrite(5,HIGH); //Send power to pin 5 digitalWrite(6,LOW); //Turn off pin 6 delay(1000); //wait 1000 milliseconds digitalWrite(5,LOW); //Turn off the power to pin 5 digitalWrite(6,HIGH); //Turn on pin 6 delay(1000); } // (c) 2017 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 
 

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!



Spread the word! Tell your friends, classmates, and family about your Hour of Code!