/* * Turn on both siren lights at once with a single button press. */ void setup(){ pinMode(5, OUTPUT); // Blue siren light pinMode(6, OUTPUT); // Red siren light pinMode(9, INPUT_PULLUP); //Button to activate the siren lights } void loop(){ //if the 9 pushbutton is pressed, turn the 5 and 6 LEDs on if (digitalRead(9) == LOW) { //the code between the braces is the 'action' digitalWrite(5,HIGH); digitalWrite(6,HIGH); } else { digitalWrite(5,LOW); //otherwise, turn the 5 LED off digitalWrite(6,LOW); //also turn LED 6 off } } //This curly brace ends the loop // (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!


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!