Digital write

To set the value of a digital pin in the Arduino programming language, we use the digitalWrite() function. This function takes the following syntax:

digitalWrite(pin, value);

The digitalWrite() function accepts two parameters, where the first one is the pin number and the second is the value to set. We should use either HIGH or LOW when setting the value of a digital pin. The following code shows how to do this:

digitalWrite(LED_ONE, HIGH);
delay(500);
digitalWrite(LED_ONE, LOW);  
delay(500);

In the preceding code, we set the pin defined by the LED_ONE constant too HIGH and then pause for half a second. The delay() function in the Arduino programming language pauses the execution of the sketch for a certain amount of time. The ...

Get Mastering Arduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.