We'll build our own sensor bar to read the track steps. We'll use five sensors. The IR sensor packages contain two small elements, an IR LED and an IR sensor enclosed in a plastic housing.

You can ignore the leg lengths (short leg doesn't mean ground in all cases) and instead use the diagram to orient things properly.

The IR LED is the clear element. It will receive power from the Crickit's 3.3V line, with a 220 Ohm resistor to reduce the voltage. The dark element is the IR phototransistor. It will send a signal to one of the Crickit's Signal input pins, using the internal pullup resistors of the Crickit. Both are tied to ground.

You can build this on a breadboard for testing; ultimately we'll solder it onto an Adafruit Perma Proto board.

Proto Board Build



To start, place the sensors into the perma-proto board as shown and solder them in place. Match the orientation and spacing shown here.


You don't have to flip the board upside down, I only did so to keep the fancy silkscreen side facing up in the final project.


Don't push them down too far, the distance from the board must be consistent from sensor to sensor -- about 12mm away from the board. This will allow us to angle the board for optimal reflection reading.



Next, add 220 Ohm current limiting resistors for each IR LED element.


Run a resistor from the V+ leg of each sensor to the + power rail on the Perma Proto board. (Note how I marked each rail to avoid confusion due to flipping the board upside down.)



Now, ground each of the sensor ground legs to the bottom ground rail on the perma-proto board with a small wire jumper.


You can ground each wire to the rail individually, or jumper them all horizontally as shown. It doesn't look pretty, but it works and won't be seen in the final project!


To connect them horizontally, strip the insulation from a length of wire that spans the width of the sensor array and then solder it down to each column with a giant, slug-like trail of solder. Admittedly, this was faster than making nine more small jumpers, but I sorta wish I had now ; ]

We'll also connect the Perma Proto board's two ground rails with a jumper wire.


To connect the sensor bar to the Crickit sensor inputs and power, we'll make some cable sets and add removable header connectors.


First, peel off a five wire section of the raw male/male jumper wires with the color set as shown.

Then, push the cable ends on either side into their own 5-pin dupont connector.


Repeat this with a red-brown pair of male/female jumper wire, and add 2-pin dupont connectors to it.


Next, use diagonal cutters to clip off a 5-pin section of the right-angled female header, and a 2-pin section of the right-angled male header. We'll use different polarities here to reduce the chance of mis-plugging something.


Solder the 5-pin header as shown.


Jumper a column to power rail and ground as shown, then add the 2-pin male header as shown, this is where the power will plug in. It is important to plug these in correctly! The color coded jumper wire helps.

Wiring the Sensors

Lastly, run a color coded jumper wire from each sensor's signal leg to the associated pin coming from the cable interconnect as shown. Solder these in place and our sensor board is ready for use!

Now, plug the cables into the Crickit's Signal I/O ports as shown.


Place the speaker wires into the two speaker terminal ports on the Crickit and screw them down firmly. You may need to strip a little extra insulation from each wire first to get a better connection.


Plug the continuous rotation servo cable into the Servo 1 port on the Crickit with the orange wire nearest to the outside edge of the Crickit.


Plug the 5V 2A DC power adapter plug into the Crickit's power barrel jack.

This guide was first published on Jan 09, 2019. It was last updated on Jun 13, 2024.

This page (Build the Sensor Circuit) was last updated on Mar 08, 2024.

Text editor powered by tinymce.