← All work
Essay

My First Robot Didn't Work

What went wrong with a line-following robot, and why the failure taught me more than the rebuild.

Essay

My First Robot Didn't Work

I spent four weekends building a line-following robot, and on the day I finally switched it on it drove straight off the table.

What I built

The robot was a small chassis with two geared motors, a battery pack, an Arduino clone, and two infrared sensors pointed at the floor. The idea is simple: the sensors read how dark the floor is, and if the left sensor sees the black line but the right one doesn't, the robot turns left. Repeat about a hundred times a second and it follows the tape.

What actually happened

It turned left. Always left. It didn't matter where the tape was, and it didn't matter if I lifted the robot off the ground entirely.

My first guess was that the right sensor was broken, so I ordered a new one. It did the same thing. My second guess was that my code had the logic backwards, so I flipped the comparison. Then it always turned right.

The real problem

The sensors were both wired to the same analog pin.

I had built the wiring from a photo in a tutorial instead of from the diagram, and in the photo the two jumper wires ran so close together that I read them as going to A0 and A1. They were both in A0. Every reading I printed was one sensor's value, twice, so of course the two sides never disagreed.

The lesson wasn't "check your wiring." It was that I trusted a picture over a diagram because the picture was easier to look at.

What I do differently now

  • I print the raw sensor values before I write any driving logic.
  • I follow the schematic and use the photo only to check my work.
  • When two things that should differ are identical, I suspect the wiring before the code.

The rebuilt robot follows a taped oval in the hallway. It's slow on tight corners, which is the next thing to fix.

What was hard, what I learned

Writing this made me go back and actually diagnose the failure instead of just saying the sensor was bad. It was the wiring. Explaining something in order is a different skill from building it.

Tools
Written in Markdown
Tags
roboticswriting