The Red Eye Special

Print Friendly, PDF & Email

Our original intention was to use Vuforia to navigate to the beacons and to grab frames from the robot controller’s camera to detect the beacon color. As we tried to learn about this technology and came to realize how complex it is to make work, we changed our plan to sense the white line for beacon alignment and to use a color sensor to figure out which button to push. Time was running out before our qualifying competition in Blue Valley on January 21st.

We installed a Modern Robotics Color Sensor on the robot, only to discover that it was defective and would not respond to its I2C interface. With no time left to wait for a replacement, we searched the junk drawers at Mr. Nelson’s shop.

He had a handful of inexpensive Cadmium Sulfide photo resistors available. These devices have a resistance that varies with the level of light falling on them. In the dark, the resistance is very high, while in bright light the resistance will fall to a few hundred ohms.

We reasoned that if we put a filter in front of the CdS device that would block red or blue light, we would be able to tell the difference by detecting the resistance change.

In the junk drawer, we found an old key chain fob from a now defunct business that was molded from red transparent flexible material. Using a paper punch and lots of muscle, we punched out some 1/4″ circles.

We then fashioned a block from a piece of the soft foamed plastic that was salvaged from last year’s FTC Res-Q mountain. We drilled and tapped a couple of holes for mounting on a Tetrix bracket and a center hole 7/32″ in diameter to hold the photo resistor and red lens.

Using an ohmmeter, we measured the resistance when looking at the lit beacon from about 6″ away. When the beacon light was red, the resistance was around 15 KΩ. When the beacon light was blue, the resistance rose to 50-60 KΩ. To interface to the computer, we could add a resistor in series with the photo resistor, connecting the string between 5V and ground, with the midpoint wired into an analog input on the Core Device Interface. The optimum range of the signal voltage will occur when the value of the series resistor is the geometric mean of the red and the blue photo resistances. Assuming 15K and 60K, this geometric mean is 30KΩ. The nearest value available in the junk drawer was 33KΩ, which was close enough. This next photo shows the wiring at the photo resistor. The red wire will connect to 5V, the black to ground, and the yellow to the analog input.

Here is the completed sensor, our Red Eye Special!

In the java software, reading the analog input gives a value of about 1.4 Volts when looking at a red beacon light from 6″ away, while a blue beacon light returns about 2.4 Volts. So the button push code is rather simple. Assuming the robot is positioned to push the left button and we are in a red alliance, we just do this:

if (redEye.analogInput() > 1.9) [move right 5 inches]; // it was blue
[push the button]