Detect a Line

Intermediate

Use the left and right line sensors to detect a dark line on a light surface. Display the sensor states on the OLED and steer LEDs based on which sensor sees the line.

20 min5 steps
Line SensorTCRT5000SensorLEDIntermediate
0 of 5 steps

Step 1 of 5

Connect your board

Power on your Beaver Board — the OLED will show a PIN code. Click Connect in the toolbar, choose Connect via Bluetooth, and select your board. If it's your first time, enter the PIN shown on the screen.

The two TCRT5000 line sensors point downward from the board: left sensor on GP4, right sensor on GP5. No extra wiring needed.

The TCRT5000 emits infrared light and measures the reflection. A dark surface absorbs the light (low reflection → true); a white surface reflects it back (false). So line detected on left is true when the left sensor is over a dark line.