chipKIT® Development Platform

Inspired by Arduino™

Last edit: 2021-03-21 22:34 by Majenko


  1. Synopsis

  2. Description

  3. Return Value

  4. Conforming To

  5. Example

  6. See Also


 void digitalWrite(uint8_t pin, uint8_t val);


The digitalWrite() function sets the logic level being output on a pin set to OUTPUT mode. The pin is the numeric (or symbolic when used with preprocessor macros) identified for the pin on the board. A val of 0 (or the symbolic name LOW) with output a LOW value (near 0V or ground) on the pin. Any other positive 8-bit value (or the symbolic name HIGH) will output a HIGH logic value (near Vdd).

To support legacy code digitalWrite() can also be used to manipulate built-in pullup resistors (when available) on a pin which is set to INPUT mode. This was the primary method used in the early (pre-1.x.x) Arduino API. Setting a pin, which is in INPUT mode, to HIGH will enable the built-in pullup resistor. Setting it to LOW will disable the pullup resistor.

Return Value


Conforming To

The pinMode() function conforms to the Arduino 1.6.x specification.


To set a pin to an output and set it HIGH:

 pinMode(13, OUTPUT);
 digitalWrite(13, HIGH);

Input with a pullup manually enabled:

 pinMode(2, INPUT);
 digitalWrite(2, HIGH);

See Also

digitalRead(), getPinMode(), pinMode(), pulseIn(), shiftIn(), shiftOut()