Description
Write the digital pin HIGH (high level) or LOW (low level).
If the pin is set to output mode (OUTPUT) by pinMode(), you can set the pin to HIGH (5V) or LOW (0V/GND) by using the digitalWrite() function.
Syntax
digitalWrite(pin, value)
pin: the Arduino pin number.
value: HIGH or LOW.
Example Code
void setup() {
pinMode(13, OUTPUT); // sets the digital pin 13 as output
}void loop() {
digitalWrite(13, HIGH); // sets the digital pin 13 on
delay(1000); // waits for a second
digitalWrite(13, LOW); // sets the digital pin 13 off
delay(1000); // waits for a second
}