The pull-down and the light
Open, the 10 kΩ ties SIGNAL to GND and the block draws nothing. Closed, SIGNAL is VCC, and current runs down the 10 kΩ and through the LED: about 1.6 mA at 3.3 V, 3.5 mA at 5 V, all from VCC and none from your pin. The 100 nF beside them carries nothing once it is charged. Read it with INPUT, never INPUT_PULLUP.
A switch needs something on the other side
A switch on its own gives your pin two states: joined to VCC, or joined to nothing. Joined to nothing, a pin floats, picks up whatever is nearby, and reads HIGH or LOW at random. The 10 kΩ from SIGNAL to GND is there so that "nothing" means 0 V. That is a pull-down, and it is why this board is active high: the resistor holds LOW, and the switch overrules it with VCC.
Close the switch and follow the dashes. Current comes in at VCC, through the balls, and splits: 0.33 mA down the 10 kΩ at 3.3 V, and about 1.3 mA down the 1 kΩ and the LED. None of it comes from your pin, which only reads the voltage. Bailin's sheet puts the closed switch under 10 Ω, so it drops at most about 16 mV of it.
The capacitor
C2, 100 nF, sits from SIGNAL to GND beside the 10 kΩ. When the balls close the switch it charges through them in about a microsecond, and after that nothing flows into it. When they lift off, it keeps SIGNAL up while the 10 kΩ and the LED drain it: about half a millisecond before an Uno reads LOW, about a millisecond on a 3.3 V board. So a ball that loses contact for less than that never shows. A rattle is not a tilt draws it.
The light shows the switch
The LED is on SIGNAL, fed through the switch, so it lights when the balls are on the contacts and not otherwise. It does not need a sketch, or even a microcontroller: VCC and GND alone are enough to see it work. When something is wrong, that splits the fault in two, which when it reads wrong uses.
INPUT, not INPUT_PULLUP
The pull-down is already on the board, so the pin needs no resistor of its
own: pinMode(pin, INPUT). INPUT_PULLUP adds the chip's internal pull-up,
which pulls the other way against the 10 kΩ while the switch is open. On an
ESP32 that lifts the open level to about 0.6 V. On an Uno, with the pull-up
at the strong end of its 20 to 50 kΩ range, it reaches about 1.7 V, more
than the 1.5 V the pin promises to read as LOW.
When it does not work
The pin's own pull-up and the board's 10 kΩ pull-down then fight while the switch is open. On an ESP32 the open level rises to about 0.6 V, still LOW; on an Uno it can reach about 1.7 V, which the pin does not promise to read as either. Use pinMode(pin, INPUT).
No. The LED and its 1 kΩ draw their current from VCC through the closed switch, not from your pin. Your pin only measures the voltage. The LED even helps the capacitor empty a little faster when the switch opens.
It is resting with its left edge down, closed, drawing about 1.6 mA at 3.3 V the whole time. Mount it so that the position it spends most of its life in is the open one, right edge down, and it draws nothing then.
Why VCC goes to 3V3 on an ESP32 and 5V only on an Uno.
VCC is your logic voltage →Edit this page — content/books/tilt-sensor/the-pull-down-and-the-light.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Tilt Sensor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.