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


 int digitalRead(uint8_t pin)


The digitalRead() function reads the logical voltage level on an I/O pin (which has previously been set to an INPUT mode with pinMode()) and returns a logical representation of that voltage level. A 1 indicates a HIGH logic level and a 0 a LOW logic level. The pin parameter represents the numeric (or symbolic when using preprocessor macros) identifier for the I/O pin on the board.

Return Value

digitalRead() will return a value of 0 if the input is LOW and a value of 1 if the input is HIGH.

Conforming To

The digitalRead() function conforms to, and expands upon, the Arduino 1.6.x specification.


Input with a pullup:

 pinMode(2, INPUT_PULLUP);
 int inval = digitalRead(2);

See Also

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