Defining Pin Levels: High and Low: High Input Output Input Pinmode Digitalread High
Defining Pin Levels: High and Low: High Input Output Input Pinmode Digitalread High
Defining Pin Levels: High and Low: High Input Output Input Pinmode Digitalread High
When reading or writing to a digital pin there are only two possible values a pin can
take/be-set-to: HIGH and LOW.
HIGH
In this state it can source current, e.g. light an LED that is connected through a series
resistor to ground.
LOW
The meaning of LOW also has a different meaning depending on whether a pin is set
to INPUT or OUTPUT. When a pin is configured as an INPUT with pinMode(), and
read with digitalRead(), the Arduino (Atmega) will report LOW if:
If you have your pin configured as an INPUT, and are reading a switch, when the
switch is in the open state the input pin will be "floating", resulting in unpredictable
results. In order to assure a proper reading when the switch is open, a pull-up or pull-
down resistor must be used. The purpose of this resistor is to pull the pin to a known
state when the switch is open. A 10 K ohm resistor is usually chosen, as it is a low
enough value to reliably prevent a floating input, and at the same time a high enough
value to not draw too much current when the switch is closed. If a pull-down
resistor is used, the input pin will be LOW when the switch is open and HIGH when the
switch is closed.
If a pull-up resistor is used, the input pin will be HIGH when the switch is open
and LOW when the switch is closed.
The Atmega microcontroller on the Arduino has internal pull-up resistors (resistors
that connect to power internally) that you can access. If you prefer to use these instead
of external pull-up resistors, you can use the INPUT_PULLUP argument
in pinMode().