collision sensor/One hit, one action/10. When a hit does nothing
One hit, one action · 10 of 10

When a hit does nothing

Push the lever in until it clicks and look at the red LED. Lit means the block, VCC and GND are fine and the fault is between SIGNAL and your sketch. Dark means the block has no supply. Then there is the lever itself: an obstacle has to push it about a millimetre and a half.

Five symptoms

When a hit does nothing
What it does
The red LED lights from VCC through the switch, with no code involved. If it stays dark when you push the lever all the way in, the block has no supply: VCC is not connected, GND is not connected, or the cable is one pin over. Count from the square pad.

Pick what the bumper is doing. The ringed part of the board is where to look first, and the list beside it is the order to check in, by how often each one is the answer.

The LED stays dark

The red LED is wired from VCC, through the switch, to ground. No code is involved, so a dark LED with the lever pushed all the way in is the supply. VCC is not connected, or GND is not, or the cable is one pin over. Count from the square pad: GND, VCC, NC, SIGNAL.

The LED lights, and the sketch sees nothing

The hit reached SIGNAL, so the block is fine. BUMPER_PIN is a GPIO number, the one printed beside the pin on your board, not a count along the header. Then the SIGNAL wire itself. Then the ground: if the block is powered from somewhere other than the board reading it, the two need a GND wire between them.

It reads a hit all the time

Most often a sketch written for an active-low bumper, which treats LOW as a hit. On this block LOW means nothing is touching; test for HIGH. Then INPUT_PULLUP, which fights the block's pull-down. And if the LED is lit too, the lever really is in: something on the robot is resting on it.

One bump counts as several

Contact bounce, and the block is fine. Add the debounce window. Doubles tens of milliseconds apart are the robot rolling back into the obstacle, which backing away on the first hit cures.

It misses glancing hits

Nothing happens until the lever has moved about 1.4 mm, and only the lever can move it. An obstacle that slides past the tip, or meets the board beside the switch, never gets it there. Then the sketch: a debounce window longer than the hit, or a delay() in loop(), can let a short touch come and go between reads.

When it does not work

How can I test the block without any code?

Wire GND and VCC only, and push the lever with a finger until it clicks. The red LED should light while you hold it and go out when you let go. If it does, the switch, the resistors and the supply are all fine, and anything left is SIGNAL's wire or the sketch.

Which ESP32 pins should I avoid for the bumper?

The flash pins, which stop the board booting if touched, and the strapping pins read at reset, 0, 2, 5, 12 and 15: a bumper held in during a reset could change how the chip starts. GPIO 25 is used here because it has no job at boot.

It worked on the desk and misses hits on the robot.

On the desk your finger pushes the lever squarely. On the robot, obstacles meet it at an angle, slide past its tip, or hit the board or the chassis beside it first. Make the lever the part that sticks out furthest, or add a light bumper plate that presses on it.

It stopped working after a crash.

Look at the lever. It is thin metal and can be bent by a hard hit, after which it may rest too far out to reach its click, or too far in to ever release. Push it with a finger and watch the LED: if it never lights, or never goes out, the switch needs replacing rather than the code.

Where this goes next

The bumper is the last sense a robot needs; the blocks page has the first ones.

Back to the blocks

Edit this page — content/books/collision-sensor/when-a-hit-does-nothing.mdx

Community

Questions about this product

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

Ask a question ↗

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.

Browse Modules and blocks on the forum