Line Avoidance

To make your bot stay in the arena, you must teach it to avoid a black line. Then you can build an arena with big white paper as the floor and black tape as the border.

Connect the Reflection Sensor

Let’s connect the reflection sensor to Arduino. Prepare the cable by cutting the end that doesn’t fit to the sensor. In our case, the small white connector fit to the sensor and we left it in place. The big black connector didn’t fit anywhere, so we cut it away. Strip the free wires for connecting to Arduino (Figure 2-6).

Stripped sensor wire

Figure 2-6. Stripped sensor wire

Connect free sensor wires to Arduino as shown in the circuit diagram for helloreflection.pde (Figure 2-7). Connect the red plus wire to +5V, and the black ground wire to GND. Connect the green data wire to D4. (Figure 2-8). Use the ScrewShield to keep the wires in place (Figure 2-9).

Circuit diagram for helloreflection.pde

Figure 2-7. Circuit diagram for helloreflection.pde

Reflection sensor connected

Figure 2-8. Reflection sensor connected

Free wires connected to Arduino with ScrewShield

Figure 2-9. Free wires connected to Arduino with ScrewShield

Hello Reflection

For line avoidance, we use a typical reflectivity sensor. We read it with Arduino’s

Get Make a Mind-Controlled Arduino Robot now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.