Write a HIGH or a LOW value to a pin configured as OUTPUT.
Writes a (digital) value to a pin.
The pin must have its mode set to OUTPUT or OUTPUT_OPEN_DRAIN.
| Parameters: | 
 | 
|---|---|
| See: | 
If the pin has been configured as an OUTPUT with pinMode() its voltage will be set to the corresponding value: 3.3V for HIGH, and 0V (ground) for LOW.
Because it is soldered to an LED and resistor in series, your board’s BOARD_LED_PIN will respond slightly more slowly as an output than the other pins.
The following example sets the built-in LED pin to HIGH, makes a one-second-long delay, sets the pin back to LOW, and delays again, causing a blinking pattern (you could also use toggleLED()):
void setup() {
  pinMode(BOARD_LED_PIN, OUTPUT);      // sets the digital pin as output
}
void loop() {
  digitalWrite(BOARD_LED_PIN, HIGH);   // sets the LED on
  delay(1000);                         // waits for a second
  digitalWrite(BOARD_LED_PIN, LOW);    // sets the LED off
  delay(1000);                         // waits for a second
}
License and Attribution
Portions of this page were adapted from the Arduino Reference Documentation, which is released under a Creative Commons Attribution-ShareAlike 3.0 License.