How it works...

We will start by defining a Led variable and setting it to represent pin 13 of the Arduino. By invoking the pinMode function, the Led variable will be indicated as the output pin, that is, it will be connected to an output device for display or to do some task.

Within the loop function, we will invoke the digitalWrite method to send a HIGH signal to variable Led. By doing so, the LED that is connected to output pin 13 will be switched on. Thereafter, we will introduce a time delay of 1,000 milliseconds.

Once more, we will invoke the digitalWrite method and send a LOW signal, this time to variable Led. As a result, the LED connected to output pin 13 will be switched off. Again, we will introduce a delay of 1,000 milliseconds. The commands in the loop function will execute infinitely making the connected LED to keep blinking.

On uploading the program to Arduino, the LED connected to the 13th pin of the Arduino will start blinking, as follows:

Figure 5.10

Voilà! We've successfully toggled the voltage in an output pin on the Arduino board to make a blinking LED.

Now, let's move on to the next recipe!