When you try to use a microcontroller to detect activity in the physical world,
the simplest activity you can perceive is whether an activity is True or False.
- Is the audience in the room or outside?
- Are they touching the table?
- Is the door open or closed?
In these cases, you can use the digital input or the switch to determine the state.
From the schematic diagram current has two directions it can go to ground:
through the resistor or through the microcontroller.
When the switch is closed, the current will follow the path of least resistance, to the microcontroller pin,
and the microcontroller can then read the voltage. The microcontroller pin will then read as high voltage or HIGH.
When the switch is open, the resistor connects the digital input to ground, so that it reads as zero voltage, or LOW.
\x95 A digital input is a board pin which can read if it sees a high (on) or low (off) logic level connected to it.
\x95 For example if you connect a button to a digital input you can detect when it's pressed and released.
\x95 Also if you connect a PIR(passive infrared sensor) to a digital input, it can detect the infrared (IR) light radiating from objects in its field of view.
\x95 MicroPython makes it just as easy to use a pin digital inputs as it does outputs.