# Line follower misses sharp turns and junctions: slow down and widen the sensor array

> Fix lost lines: lower the speed on curves, remember the last side the line was seen on and use more sensors, spaced for your line width.

Canonical: https://roboticsengineering.in/fix/line-follower-misses-junctions-and-sharp-turns-speed-too-high/ | Published: 2026-11-03 | Updated: 2026-11-04

**Remember the side where the line was last seen, and slow down in turns.**

## What the message means

A fast robot leaves the line between sensor readings. With no sensor on the line it does not know which way to turn.

## Fix it in this order

1. Store the last direction in which the line was detected.
2. When all sensors see white, turn towards that side.
3. Lower the speed when the error is large.
4. Check that sensor spacing fits the line width.
5. Mount the sensors closer to the front wheels or the line.
6. Calibrate the black and white values on the actual surface.

## Why it happens

At high speed the robot reaches a sharp turn or junction before the code can react, so it overshoots and loses the line. The sensors only see the line when they are over it, so the robot needs time and distance to turn.

Lower the base speed, slow down when the outer sensors see the line, and move the sensor bar further forward or widen it so the turn is detected earlier.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Leaves the line on curves | Too fast. |
| Spins in place when it loses the line | No memory of last side. |

## Related

[line sensor calibration](https://roboticsengineering.in/fix/line-follower-sensor-threshold-black-white-calibrate/), [line follower wobbles](https://roboticsengineering.in/fix/line-follower-oscillates-wobbles-pid-too-high/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

## Why this happens

A line follower can only act on what its sensors see at the moment it reads them. At speed v and loop time T, the robot moves v x T between reads. At 0.5 m/s with a 20 ms loop it moves 10 mm. If the sensors are only a few millimetres wide and the robot is already across a sharp bend, the line is simply not under any sensor in the next read.

Lost-line behaviour decides what happens next. With no memory, the robot has no idea which way to turn and drives straight on. Slowing down in turns and keeping the last known side makes the recovery reliable. Sensor position matters as well: sensors further ahead of the wheels see the bend sooner.

## How to confirm the cause

- Log the sensor pattern together with millis(). The pattern just before the failure shows which side lost the line.
- Run the same track at three speeds. If it fails only at the higher ones, speed is the cause.
- Measure the loop time with micros() and compute the distance per loop.
- Check the sensor height. Reflectance sensors usually work best a few millimetres above the surface.

## Worked example

The remembered side is used when all three sensors lose the line.

```
const int BLACK = HIGH;          // output level over the line, check yours
static int lastSide = 0;         // -1 left, +1 right

bool l = digitalRead(L_PIN) == BLACK;
bool c = digitalRead(C_PIN) == BLACK;
bool r = digitalRead(R_PIN) == BLACK;

if (l) lastSide = -1;
if (r) lastSide = +1;
if (!l && !c && !r) {            // line lost
  if (lastSide < 0) spinLeft(); else spinRight();
}
```

## Common mistakes

- Tuning the controller at one speed and expecting it to work at all of them.
- Spacing sensors wider than the line and the gap between them.
- Reading sensors with long delays in the loop.
- Ignoring battery sag, which changes speed over a run.

## If this did not fix it

- Check sensor calibration on the actual surface.
- Check motor speed mismatch, which pulls to one side.
- Check wheel slip on glossy floors.
- Check the junction logic separately from simple curves.
