/* * Turn on each siren light with a different button */ void setup(){ pinMode(5, OUTPUT); // Blue siren light pinMode(6, OUTPUT); // Red siren light pinMode(9, INPUT_PULLUP); //Button for the blue light pinMode(10, INPUT_PULLUP); //Button for the red light } void loop(){ //if the 9 pushbutton is pressed, turn the 5 LED on if (digitalRead(9) == LOW) { digitalWrite(5, HIGH); //the code between the braces is the 'action' } else { digitalWrite(5,LOW); //otherwise, turn the 5 LED off } if (digitalRead(10) == LOW) { //if the 10 button is pressed digitalWrite(6,HIGH); //turn on the 6 LED } else { digitalWrite(6,LOW); //otherwise, turn the 6 LED 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!


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!