In this episode we would modify the blinking diode program so that the diode will stay on for four seconds.
- #316
- 15 Nov 2016
- 1:39
Delay
In the example program for the blinking diode there is a function called loop written as:
void loop() {
...
}
Find this function in your program. In the body of the function you will see a line:
delay(1000);
This is a call to a function called delay. The program says to the computer to call this function and it will delay the execution of the next line with 1000 milliseconds. 1000 milliseconds is exactly 1 second.
Two delays
There are two delays in the program. The first delay is waiting for 1 second after the diode is turned on and the second delay is waiting for the diode to say off for 1 second. Let's change the value of the first delay to 4000 and upload the program to the controller.
English
Our next step is to modify the program for this blinking diode so that is stays on for 4 seconds.
In the program this here is the program for the blinking diode. And in this program we'll discuss it in greater details what exactly are functions, what are the variables what is everything in this software. But for now you must find this function called loop. And here you have two calls to a function called delay. And here you have a value. And this value currently is 1000. The other value is also 1000. So, these are the two waits. This is the wait of how long do you want the diode to stay on. And this is the wait of how long should the diode stay off. Now, let's change the value here to 4. And upload the program to the controller. End result. The diode blinks for 5, so it blinks but it stays on for 5 seconds.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons
Starting with Electronics and Arduino
Robotics is great. Mindstorms are great. But for a student to take the next step he or she needs to take a step back, learn what's 'below' and from there discover what would be 'above'.
So we, the content creators at FLLCasts, in order to teach the world of electronics and prepare the next generation of creators from the youngest age, by presenting knowledge, asking questions and searching for the answers of these questions, are building this course for basic electronics with Arduino, that we call "Starting with Electronics and Arduino".
The course is still in development
- 16
- 25:27
- 6

Getting started. Unpacking. First device and program
Why: It's an easy and fun example to introduce you to Arduino
How: Presenting questions and trying answer this questions. Experimenting with different tasks.
What: We would like to show you how to control a diode. We would build a device and write programs for this device.
End Result: A blinking diode
- 11
- 0
- 6
- 3d_rotation 2