В момента ресурсът е наличен само на английски

Arduino Basic Course. Modify the blinking diode program Pro Preview

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.

Курсове и занятия включващи този Урок

Този Урок е използван в следните курсове и занятия.

Image for Starting with Electronics and Arduino
  • 16
  • 25:27
  • 6
Image for Getting started. Unpacking. First device and program
  • 11
  • 0
  • 6
  • 3d_rotation 2