DigitalWrite

From chipKIT
Jump to: navigation, search

Synopsis

 void digitalWrite(uint8_t pin, uint8_t val);

Description

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

None

Conforming To

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

Example

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()