The pull-down and the light
A 10 kΩ resistor from SIGNAL to GND holds the pin at 0 V while nothing touches the lever, and a red LED behind 1 kΩ lights whenever SIGNAL is HIGH. At rest the block draws no current at all; on a hit, about 3.5 mA from 5 V.
The whole board in one drawing
VCC goes to the switch. From the switch's NO contact, SIGNAL goes to your pin and, on the board, two ways to ground: the 10 kΩ pull-down, R3, and the 1 kΩ resistor, R4, with the red LED after it. That is every part on the board.
The pull-down
An input pin with nothing connected to it reads whatever stray charge is on it, HIGH and LOW at random. At rest the switch connects SIGNAL to nothing, so without R3 that is what your pin would do, and a robot would stop for walls that are not there.
R3 ties SIGNAL to ground. At rest no current flows through it, so there is no voltage across it, and SIGNAL sits at 0 V: LOW, every time. On a hit the switch connects SIGNAL straight to VCC, which overrules a 10 kΩ resistor outright. The push button uses the same resistor for the same job, and its book shows the floating pin in a figure.
Two rules follow, and every sketch here keeps both: pinMode(pin, INPUT),
not INPUT_PULLUP, and HIGH is a hit.
The light
The LED lights whenever SIGNAL is HIGH, from the wiring alone. So on a hit it shows the block works before you have written a line of code, and later it splits every fault in two: lit means the fault is between SIGNAL and your sketch, dark means the block has no supply.
Its current is worked out rather than measured. The LED is red, and a red 0805 LED drops about 2.0 V at these currents:
from 5 V: (5.0 V - 2.0 V) / 1 kΩ = about 3 mA, plus 0.5 mA in R3
from 3.3 V: (3.3 V - 2.0 V) / 1 kΩ = about 1.3 mA, plus 0.33 mA in R3That current flows only while the lever is held in, and it comes from the block's VCC pin, not from your input pin. At rest the block draws nothing.
When it does not work
No, use INPUT. The block already has its pull-down. Switching on the chip's internal pull-up as well puts two resistors in a tug of war on SIGNAL, and at rest it settles somewhere around a volt: not a clean LOW, and not a level any datasheet promises to read the same way twice.
Not while nothing touches the lever. At rest the switch connects VCC to nothing, so no current flows through the pull-down or the LED. Current flows only while the lever is held in: about 3.5 mA from 5 V, about 1.6 mA from 3.3 V.
Normal. A red LED takes about 2.0 V before it conducts, and 3.3 V leaves about 1.3 V for its 1 kΩ resistor: roughly 1.3 mA. On a 5 V Uno the same LED gets about 3 mA and is plainly brighter.
Not from code. It is wired to SIGNAL, so it lights whenever the lever is in and VCC is connected. That is the point of it: it shows the hardware is working even when the sketch is not.
Why the block's VCC pin goes to 3V3 beside an ESP32 and 5V beside an Uno.
VCC sets the voltage →Edit this page — content/books/collision-sensor/the-pull-down-and-the-light.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Collision 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.