Intuition The ONE core idea
A GPIO pin is a single wire that a tiny computer can either push a voltage onto (output) or feel the voltage of (input) — and everything else (resistors, interrupts, active-LOW logic) is just machinery for making that one wire reliable and responsive . Master three pictures — a wire with two possible heights, a resistor gently holding that height, and a "tap on the shoulder" when the height jumps — and the whole parent note becomes obvious.
This is the D1 foundations page. The parent note (GPIO topic ) throws a lot of symbols at you: V D D , GN D , HIGH/LOW, R , I , "Hi-Z", "edge", volatile. Below we build every one from absolute zero — plain words first, then the picture, then why the topic can't live without it .
Voltage is the electrical push between two points, measured in volts (V) . Think of it as a height : a point that is "high up" wants to push charge downhill toward a point that is "low down".
The picture: imagine every wire as a water tank at some height . Water (charge) flows from a tall tank to a short one. Voltage is how tall the tank is compared to the floor .
We always measure height relative to something . That reference floor is called ground .
GN D
Ground (symbol GN D ) is the agreed zero-height reference — the floor. We define it as 0 volts. Every other voltage in the circuit is measured "how far above the floor".
Definition Supply voltage
V D D
V D D is the highest voltage the chip runs on — the top of the tank, the "ceiling". Common values: 3.3 V or 5 V . The subscript D D is old transistor jargon (drain supply); just read it as "the positive rail".
Why the topic needs these two: every single sentence about a pin being "HIGH" or "LOW" secretly means "close to V D D " or "close to GN D ". Without a floor (GN D ) and a ceiling (V D D ), the words HIGH and LOW are meaningless.
A digital wire only cares about two heights :
HIGH = near the ceiling V D D = we call it logic 1 .
LOW = near the floor GN D = we call it logic 0 .
Anything clearly near the top counts as 1, anything clearly near the bottom counts as 0. The messy middle is "undefined" — we avoid it.
The picture: a light switch has only up and down . There is no "half-on" that the digital world respects.
Why the topic needs it: reading a button, driving an LED, firing an interrupt — all of it is the CPU deciding "is this wire a 1 or a 0?"
An output pin is one the CPU drives : it forces the wire to a height it chooses (HIGH or LOW). The CPU is the water pump.
An input pin is one the CPU senses : it just measures the wire's height without forcing it. The CPU is a thermometer, not a pump.
Intuition Why they are physically different
Pushing (output) needs a strong pump that can shove charge out or suck it in. Feeling (input) needs a super-gentle sensor that takes almost no charge — otherwise it would disturb the very thing it measures. That is why chips keep separate registers for "what I write" vs "what I read": they are two different pieces of hardware on the same pin.
Why the topic needs it: the entire note splits into "output half" (push-pull, open-drain) and "input half" (pull resistors, floating, interrupts). This is the root fork.
I
Current is the flow rate of charge — how much water passes per second — measured in amperes (A) . Small flows use milliamps (1 mA = 0.001 A ) or microamps (1 μ A = 0.000001 A ).
R
Resistance is how much a component fights the flow , measured in ohms (Ω ). A thin, kinked pipe = high resistance = little water gets through.
Intuition Why THIS tool, not something fancier?
We need to answer: "If a pull-up resistor ties the pin to V D D and a pressed button ties it to GN D , how much current gets wasted?" That is a straight push-through-a-pipe question — the simplest possible electrical relationship. Ohm's Law is the exact tool: it links the three quantities we already have (V D D , R , I ) with nothing extra. No calculus, no time — the situation is steady, so a plain ratio is all we need.
Worked example The parent's pull-up calculation, from zero
The chip runs at V D D = 3.3 V . When the button is pressed the whole 3.3 V sits across the pull-up resistor R , so current flows straight to ground. We want that wasted current at most 100 μ A .
R ≥ I V D D = 100 × 1 0 − 6 3.3 = 33 , 000 Ω = 33 k Ω
Bigger R = less wasted current, but too big and noise wins (section 6). See Pull-up Resistor Sizing & Ohm's Law for the full trade-off.
Why the topic needs it: choosing a pull resistor value is nothing but this equation.
Definition Impedance and Hi-Z
Impedance is resistance's general cousin — again "how hard it is for current to flow". High-impedance (Hi-Z ) means resistance so enormous that almost no current flows at all — effectively the wire is disconnected .
The picture: a pipe with a valve shut so tight that no water moves. The pipe is there , but electrically it's as if you snipped it.
Intuition Why Hi-Z matters
Two uses in the parent note:
An input pin is deliberately near-Hi-Z so it barely disturbs what it measures.
An open-drain output can let go of the wire (go Hi-Z) so another device can drive it — this is how shared buses like I²C work.
The danger: a Hi-Z pin with nothing else connected is floating (next section).
Intuition The floating picture
A Hi-Z input pin holding no charge is like a swing hanging in the wind — the tiniest breeze (electrical noise from nearby wires, mains hum, your finger) nudges it up or down. Read it and you get a random 1 or 0.
Definition Pull-up / Pull-down resistor
A weak (large, ≈ 10 –50 k Ω ) resistor that gently ties a floating pin to a known height:
Pull-up → resistor to V D D → idle reads HIGH (1) .
Pull-down → resistor to GN D → idle reads LOW (0) .
Intuition Why "weak" = large resistance
"Weak" means it holds the pin just firmly enough to beat noise, but loosely enough that any real driver instantly overrides it. A soft rubber band, not a steel cable. When a strong output (a few ohms) fights a 33 k Ω pull-up, the strong side wins by thousands to one — see Switch Debouncing and the parent's divider argument for the exact numbers.
Why the topic needs it: this is the fix for the "#1 beginner bug" — a button that reads pressed when untouched.
A signal is active-LOW when the interesting event drives it to 0 , and its idle/resting state is 1 . The standard button wiring is active-LOW: pull-up idle = HIGH = 1, pressing connects the pin to GN D = LOW = 0.
The picture: the "alarm" is the wire dropping to the floor, not rising to the ceiling.
Why the topic needs it: because internal pull-ups are common and grounding is electrically clean, real hardware reads "pressed = 0", which surprises beginners. Naming it removes the surprise.
Definition Rising / falling edge
An edge is the moment a wire changes level:
Rising edge : 0 → 1 (jumps up).
Falling edge : 1 → 0 (drops down).
An edge is an event in time , not a steady state.
The picture: the wire's height plotted against time looks like a staircase. The vertical step is the edge — that instant of jump.
Intuition Why we care about the edge, not the level
A button press is a transition, an event that happens once. We want to react once per press , so we watch for the falling edge (active-LOW). Watching the level ("while LOW") would keep re-reacting the whole time you hold the button.
Why the topic needs it: interrupts fire on edges. No concept of "edge", no concept of "interrupt on pin change".
Definition Interrupt and ISR
An interrupt is hardware yanking the CPU away from its current work the instant a chosen event (like a falling edge) happens. The special function it jumps into is the ISR = Interrupt Service Routine .
Intuition Polling vs interrupt
Polling : the CPU asks "changed yet? changed yet?" a million times a second — exhausting, and it can blink and miss a fast pulse.
Interrupt : the CPU does other work; the wire taps its shoulder the moment it changes.
Compare the two styles in depth at Polling vs Interrupt-Driven I/O and design ISRs well with Interrupts & ISR Design .
Why the topic needs it: the whole "interrupt on pin change" half of the note is this idea. The rule "keep the ISR tiny, clear the flag" all flows from here.
volatile is a keyword you put on a variable shared between the ISR and the main code. It tells the compiler: "this value can change behind your back — always re-read it fresh from memory, never cache it."
Imagine you wrote a number on a whiteboard, then kept reciting it from memory. If a sneaky friend (the ISR) quietly changes the whiteboard, you'd never notice — you're reciting your stale memory. volatile forces you to look at the whiteboard every single time . Details at volatile & Memory-Mapped Registers .
Why the topic needs it: without it, an optimized build caches the shared flag and the main loop never sees the ISR's update — the parent's "works in debug, breaks with -O2" bug.
Cover the right side and answer each before reading the parent note:
What is voltage, in one picture? The height of a wire's electrical push, measured relative to ground (the floor).
What does GN D mean and what is its voltage? Ground — the agreed zero-height reference, defined as 0 V.
What does V D D represent? The chip's supply voltage — the top rail / ceiling (e.g. 3.3 V or 5 V).
HIGH and LOW correspond to which logic values and which heights? HIGH = logic 1 = near V D D ; LOW = logic 0 = near GN D .
What is the difference between an input pin and an output pin? Output drives (pushes) the wire to a chosen level; input senses (feels) the wire without forcing it.
State Ohm's Law and the rearranged form the topic uses. V = I ⋅ R , rearranged to I = V / R .
For a 3.3 V pin capped at 100 µA, what pull-up value do you get? R ≥ 3.3/ ( 100 × 1 0 − 6 ) = 33 k Ω .
What does high-impedance (Hi-Z) mean? Resistance so huge that essentially no current flows — the wire acts disconnected.
What is a floating pin and why is it bad? An undriven input that picks up noise and reads a random 1 or 0.
Pull-up vs pull-down: what idle level does each give? Pull-up → idle HIGH (1); pull-down → idle LOW (0).
What does "active-LOW" mean for a button? Idle reads 1; the pressed event drives the pin to 0.
Define rising edge and falling edge. Rising = 0 → 1 ; falling = 1 → 0 — the instant the level changes.
What is an ISR? Interrupt Service Routine — the function the CPU jumps to when an interrupt fires.
Why must an ISR-shared flag be volatile? So the compiler re-reads it from memory each time instead of caching a stale copy.