Beginner robot using a simple voltage comparator to follow a line


Sandwich is a line following robot. He’s the first robot I ever made. His body is made from a plastic sandwich container which is where his name comes from. Sandwich has photocells for sensors and an analog comparator for brains. Add in a 9V battery, a pair of DC gearhead motors and some decorative LEDs, and you’ve got a fun little guy who zips around the living room tormenting the dog.

The idea, plans, and instructions for Sandwich come from Robot Building for Beginners by David Cook. I found it when a web search landed me on his web site Robot Room. Such a fantastic book, it walks you through all stages of construction of a line following robot with lots of pictures and simple language. It goes into great detail about each phase of construction starting from the planning phase and continuing through prototyping, construction, troubleshooting, and enjoying.

Now, on to some of the highlights of my Sandwich the Line Following Robot…


Before I get into some specifics, I’ll give you some eye candy…

The first picture illustrates a couple of points. Firstly, you can see that Sandwich can follow a crack in the basement floor. I had to put the white paper there to provide high-contrast to get him to leave the crack and resume following the tape. Secondly, before I began work on Sandwich, I waterproofed my basement/workstation. I’ll give you one guess what percentage of my basement floor was part of that home improvement.

They say that animals can sense evil? The second picture shows Sandwich rudely sitting in Ollie’s spot on the couch. Watch the video for some more details about how Ollie and Sandwich became acquainted.

Solderless Prototype

Sandwich Prototype

The first part of building Sandwich is to build the circuit modules on a solderless prototype board. This is a really fun part of the process because you get to play around with the components. In the picture, you can see the power switch and indicator LED, the balanced light-sensing module, the comparator module, the two transistor-driven LED modules, and an extraneous trimpot thrown in there because I didn’t want to lose it. The Robot Building for Beginners book walks you through planning, calculating, constructing, and measuring the whole circuit.

Soldering, Schmoldering

Once the prototype is functional, its time to solder some more permanent circuits together. This is definitely where my skills and the skills needed for robot making are completely unrelated to one another. You can see the pictures of my soldering iron tips that are so oxidized that they actually started melting and corroding. These tips were really inexpensive and the iron I had them in cost about $2.50. I suppose you get what you pay for because my initial experience with soldering was brutal. There’s also a picture of part of the motherboard where I heated it too much and even melted a copper trace off of the board.

NOTE: I'm not trying to demonstrate proper soldering, I'm just trying to show off how horribe my original technique and tools were.

Before I finished Sandwich, I ended up going for a better Weller WP35 solering iron and some of the good pre-tinned tips. Soldering was way better with the right equipment.


wooden dowel

Robot builders are very familiar with improvisation. Things don’t quite line up just right, or you have “almost” the correct part lying around, or you’re trying to hack a toy into something else and along the way, you’ve got to be ready to improvise a solution that’s not in the book or datasheet or manual.

My first taste of this was when my motor stopped working after I soldered the lead wires to it. Intermittently it would switch on and off. Through experimentation I noticed that if I kept pressure on the black wire pushing it out towards the outside of the motor, then the intermmitent problem dissappeared. So during soldering I must have partially melted its internal connection. I didn’t want to be frivolous by throwing the motor away, so I wedged in a little piece of wooden dowel that I had laying around, and the problem was solved.

Heatshrink Tubing

burned tubing

Throughout the book, David Cook is continuously reinforcing how proper use of heatshrink tubing separates the losers from the winners. In addition to the improved physical strength of joints and protection from short circuits, the tubing gives a robot a more professional look which creates a better image for the robot overall.

But does it really look professional if you use a flame to activate the tubing? I don’t think so. My first attempt with a hairdryer or two failed miserably and so I used a lighter. This is literally “playing with fire” and I quickly was convinced that a heat gun is the way to go for safety, appearance, and heat shrink quality.


Here’s the motherboard as seen from the top. It should look quite familiar if you’ve also been through the book because I tried to exactly follow the suggested layout. You can see one of the yellow LEDs was not firmly pressed in place before soldering. If you look real close at the Molex KK headers, you can see the dried Liquid Nails that I had to use since I can’t find silicone adhesive anywhere. The two bare wires sticking out of either side are the power bus lines that I didn’t clip off yet.

In Conclusion

In conclusion, building Sandwich was a great first robot experience. He is sophisticated enough to challenge a brand newbie, and yet simple enough to be realistic. I became acquainted with various components, tools, techniques, suppliers, and manufacturers. For me, Sandwich was also an excuse to waterproof and upgrade the lighting in my basement and to refurbish my workbench. After some debugging and troubleshooting, watching Sandwich scoot around the floor has been really rewarding.