10 Constant Delay Variable

Jumbo LED Blink Sequence

/* Blink each color of the jumbo LEDs, using a variable to control the speed */ int wait = 1000; //create a variable, named 'wait', with a type of 'int', which means it will be a whole number - no decimals //Variables can be named almost anything. Names can't start with numbers or use other keywords from the code, like 'void' void setup(){ pinMode(8,OUTPUT); //LED pinMode(9,OUTPUT); //LED pinMode(10,OUTPUT); //LED pinMode(11,OUTPUT); //LED } void loop(){ digitalWrite(8,HIGH); //Turn on LED 8 delay(wait); //delay for an amount of time equal to wait. Here it is 1000 milliseconds (1 second) digitalWrite(8,LOW); //Turn off LED 8 delay(wait); //delay for 'wait' amount of time digitalWrite(9,HIGH); //Turn on LED 9 delay(wait); //delay for an amount of time equal to wait. Here it is 1000 milliseconds (1 second) digitalWrite(9,LOW); //Turn off LED 9 delay(wait); //delay for 'wait' amount of time digitalWrite(10,HIGH); //Turn on LED 10 delay(wait); //delay for an amount of time equal to wait. Here it is 1000 milliseconds (1 second) digitalWrite(10,LOW); //Turn off LED 10 delay(wait); //delay for 'wait' amount of time digitalWrite(11,HIGH); //Turn on LED 11 delay(wait); //delay for an amount of time equal to wait. Here it is 1000 milliseconds (1 second) digitalWrite(11,LOW); //Turn off LED 11 delay(wait); //delay for 'wait' amount of time } // (c) 2024 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

 

Challenges

Can you complete the challenges? Change the code in your code editor above. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!


TRANSFORMERS and HASBRO and all related trademarks and logos are trademarks of Hasbro, Inc. ©2024 Hasbro.