INPUT vs INPUT_PULLUP
Why a floating pin lies and how pull-ups fix it.
Pins Can Listen Too
So far your pins pushed signals out. Now you'll make a pin listen instead, so your board can sense a button and react to it.
Set a Pin as INPUT
To read a button, you first tell a pin it should receive a signal. You do that by setting its mode to INPUT inside setup().
void setup() {
pinMode(2, INPUT);
}All lessons in this course
- INPUT vs INPUT_PULLUP
- Reading a Button State
- if/else: LED Follows the Button
- Wire a Button on a Breadboard