speed sensor/How it works/05. VCC is your logic voltage
How it works · 05 of 10

VCC is your logic voltage

SIGNAL's HIGH is VCC through a 10 kΩ pull-up, so VCC decides what your board's pin sees. 3V3 on an ESP32, an ESP32-S3 or a Pico; 5V on an Uno. 5V beside a 3.3 V board pushes SIGNAL past the pin's supply every time something enters the slot.

The pin sees VCC

When the slot is blocked, the comparator lets go of SIGNAL and R7 pulls it up to VCC. There is nothing else in the way, so HIGH on SIGNAL is whatever voltage you wired VCC to. LOW is the comparator's 0.15 V, whatever VCC is.

VCC is your logic voltage
Your board
VCC wired to
SIGNAL blocked
5 V
ESP32-S3 runs at
3.3 V
Wire VCC to
3V3
Wrong. With the slot blocked, the 10 kΩ pull-up lifts SIGNAL toward 5 V on a pin whose own supply is 3.3 V. The pin's protection diode clamps it and about 140 µA flows into the chip's supply through it, every time something passes the slot. The resistor keeps that small, but it is outside the pin's ratings. Move VCC to 3V3.

Pick your board and try both supplies:

  • ESP32, ESP32-S3, Pico: 3V3. Their pins run at 3.3 V and read HIGH from 2.5 V (ESP32 family) or 2.0 V (RP2040). 3.3 V on SIGNAL is right.
  • Uno: 5V. Its pins run at 5 V and need 3.0 V to be sure of HIGH. 3.3 V scrapes in; 5 V is right.
  • 5V beside a 3.3 V board lifts SIGNAL toward 5 V. The pin's protection diode catches it and about 140 µA flows into the chip through it, every time something passes the slot. The 10 kΩ keeps that small, but it is outside the pin's ratings, and on a Pico VBUS is the same mistake.

The block does not mind

The LM393 runs from 2 V upward and the slot sensor's LED only needs a little over 1 V, so the block works from 3.3 V as well as from 5 V. At 3.3 V the infrared LED gets about 2.2 mA instead of 3.9 mA, and the light sensor passes less with it; a beam across a slot says what that means for the margin.

When it does not work

SIGNAL reads 5 V on my ESP32's pin.

VCC is on 5V. SIGNAL is pulled up to whatever VCC is, and the ESP32's pins are 3.3 V pins. Move VCC to 3V3; the comparator and the slot sensor both run from 3.3 V.

Does the block work from 3V3 on an Uno?

It reads HIGH, but only just: 3.3 V against the 3.0 V an Uno's pin needs to be sure of HIGH. It works on a bench. Give it 5V on an Uno and the margin is the whole supply.

Could I use 5V and a resistor divider on SIGNAL instead?

You could, but there is no reason to. Every part on the block is happy at 3.3 V, so 3V3 on VCC gives a 3.3 V SIGNAL with no extra parts. The infrared LED is a little dimmer at 3.3 V, which the block is designed around.

Alongside this page
Where this goes next

Three wires and a sketch that prints each time something passes.

The first read →

Edit this page — content/books/ir-speed-sensor/vcc-is-your-logic-voltage.mdx

Community

Questions about this product

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

Ask a question ↗

Infrared Speed 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 →