โ† Arduino learning path
Arduino ยท Module 3 of 10

Digital input and buttons

Read buttons and switches.

๐Ÿ“– Key ideas

  1. digitalRead(pin) returns HIGH or LOW.
  2. Use INPUT_PULLUP to avoid floating pins.
  3. With pull-up, pressed button reads LOW.
  4. Debounce buttons in software.
  5. Use if statements to react to input.
๐Ÿ’ก Real-life example: A button is a doorbell; digitalRead checks whether someone is pressing it.
digitalReadReads HIGH/LOW from a pin
INPUT_PULLUPEnables internal pull-up resistor
Floating pinUnconnected input giving random values
DebounceFiltering button noise