4-direction tilt sensor/How it is wired/04. The lights wait for you
How it is wired · 04 of 11

The lights wait for you

Each line has a red LED that hangs from VCC through 1 kΩ onto the line itself. It lights only while your board holds that line LOW: about 3 mA from 5 V, about 1.3 mA from 3.3 V. Wire VCC and GND alone, tip the board, and nothing lights. The LEDs show what the sketch is doing, not what the roller is doing.

An LED on every line

Each of the four lines has its own LED and its own 1 kΩ resistor. The resistor's top end is on VCC; the LED's bottom end, its cathode, is the line. Current can only flow down through them, from VCC into the line, and only when the line is well below VCC.

Most of the time it is not. A line that is released is an input with your board's pull-up, which holds it near your board's supply. With VCC at that same voltage, the LED has nothing across it and stays dark.

Lit means held LOW

Lit means held LOW
Your board
VCC
LED A
dark
LED B
dark
Pin A sinks
nothing
Nothing is held LOW. Each line sits at the pull-up in your board's pin, which is near VCC, so each LED has almost nothing across it and stays dark. The roller can be anywhere: joining two lines that are both HIGH lights nothing. This is why the LEDs are dark when the block is only powered.

Hold A LOW and its LED has the whole of VCC across it and its resistor. A red LED takes about 2.0 V of that, the 1 kΩ takes the rest, and about 3 mA flows from 5 V, or about 1.3 mA from 3.3 V. Your board's pin sinks it.

If the roller is joining B to A at that moment, B is LOW too, and B's LED lights as well. Its current comes through the roller and into the same pin: about 6 mA from 5 V. That is comfortably inside what an Uno, an ESP32, an ESP32-S3 or a Pico pin can sink.

These are worked out from a red LED's typical forward voltage and a pin's LOW taken as 0 V, not measured. The parts list names a green LED; the boards are fitted with red ones.

Dark with only power

So a TK19 with VCC and GND wired and nothing else is dark, tipped any way you like. Nothing is holding any line LOW. The switch never touches GND, so it cannot light anything by itself.

That is the reverse of most blocks in the kit, where the light answers the sensor with no code involved. Here the light answers the sketch. With the first read's sketch, each line is held LOW for microseconds per scan and the LEDs look dark. Lighting the low side holds the downhill pair LOW between scans, and turns the four LEDs into a display.

When it does not work

I powered it and tilted it, and no LED lights.

That is correct. The LEDs light only when your board holds a line LOW, and with VCC and GND alone nothing holds any line. Wire A, B, C and D and run the first read, or better, lighting the low side, which keeps the downhill pair lit.

The first read's sketch runs and the LEDs still look dark.

They are lighting, for a few microseconds each scan: that sketch holds each line LOW only long enough to read its neighbours. The eye cannot see that. The lighting sketch holds the low pair LOW between scans, and then they stay visibly lit.

Can the LEDs damage my board's pins?

No. A pin holding a line LOW sinks that line's LED current, about 3 mA from 5 V, and about 6 mA if the roller joins a second line to it. Every board in this book is comfortable with that. The limit that matters is VCC, which has to match your board's own voltage.

The LEDs look green in the parts list.

The parts list names a green LED part, but the boards as shipped carry red ones. The currents in this book are worked out for a red LED's forward voltage, about 2.0 V, and they are estimates rather than measurements.

Where this goes next

Why the block's VCC goes to 3V3 beside an ESP32 and 5V beside an Uno.

VCC must match

Edit this page — content/books/four-direction-tilt-sensor/the-lights-wait-for-you.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

4-Direction 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.

Browse Modules and blocks on the forum