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.
digitalRead() will return a value of 0 if the input is LOW and a value of 1 if the input is HIGH.
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);