0Pricing
Arduino & IoT Academy · Lesson

Polling vs Interrupts

Why some events can't wait for the loop.

Always Checking

So far your loop uses polling: it runs around and around, asking each sensor and button over and over whether anything changed.

Polling in Action

A typical poll reads a pin every pass of the loop. If the value matches what you want, you react; otherwise you simply keep looping. 🔁

if (digitalRead(buttonPin) == LOW) {
  doSomething();
}

All lessons in this course

  1. Polling vs Interrupts
  2. attachInterrupt on a Pin
  3. Writing a Safe ISR
  4. Count Pulses from an Encoder
← Back to Arduino & IoT Academy