arduinoDigital Inputs


Syntax

  • pinMode(pin, pinMode) // Sets the pin to the mode defined.
  • digitalRead(pin); // Reads the value from a specified digital pin,

Parameters

ParamterDetails
pinmodeShould be set to INPUT or INPUT_PULLUP

Remarks

If the input pin is not pulled LOW or HIGH, the value will float. That is, it won't be clearly a 1 or a 0, but somewhere in between. For digital input, a pullup or pulldown resistor is a necessity.