I realize that I’ve been remiss on my survey of VEX sensors and have not yet covered light sensors. Previous posts have reviewed potentiometers, bumper/limit switches, shaft encoders, line tracker, ultrasonic rangefinder, LEDs & jumper clipsgyro, and accelerometer.

I haven’t written anything in-depth because this is a sensor that gets very, very little use in competitive robotics. So here I present the facts and some resources. My team tried to use it in Nothing But Net to see when a ball was being moved up a ramp to the flywheel, but we couldn’t find a decent place to mount it, and in the easyC online window it didn’t seem all that responsive. But we honestly didn’t try that hard to figure it out, since we had no place to put it.

The Specs

Cost: $20 for one sensor (VEX product page).

This analog light sensor is designed to “read” ambient light, and returns a value from 0 to 255 (easyC) or 0 to 4095 (RobotC), with 0 being brightest, and large numbers being darkest.

Analog sensors work by returning a voltage (from 0 to 5V) back to the cortex, which is then converted into a number you can use. The light sensor uses a component known as a photoresistor, which changes its resistance based on the ambient light level:

  • bright light = high resistance = returns low voltage to cortex = low sensor value
  • dark area = low resistance = returns high voltage to cortex = high sensor value

Its range of operation is 0 to 6 feet. Since the photoresistor is sensitive only to the visible light spectrum, the light sensor does not work for detecting (and is not impacted by) infrared or ultraviolet light.

Uses

As described in the VEX product info sheet, this sensor can be used to “steer” a robot. One can program a robot to move away from dark areas, or to move toward a light source.

RobotC has sample code for a robot that drives toward a light source using 2 light sensors installed on each side of the robot. The code is analogous to line-following, adjusting left- and right-side power to drive toward a target.

One thing that’s done in this code and mentioned elsewhere is the importance of calibrating the light sensor when you are using it. You can’t calibrate it in your lab and then take it to a gymnasium and expect it to work the same. You want to calibrate it in the program each time its run; this can be done in the pre-autonomous (RobotC) or initialize (easyC) period of a competition program. The RobotC page with sample code has instructions in it that does the calibration. (You can also see code from Griffin Tabor for doing this calibration on the field with a line-tracker in a post I wrote a few months ago.)

The other use that’s mentioned frequently in combination with this product is to put a colored filter (e.g., piece of cellophane) over the sensor to turn it into a color sensor instead of a light sensor. Again, in competition situations, it seems unlikely that many teams are going to make a lot of use of this option, but it is mentioned specifically in the rule manual as something you are allowed to do:

<R7> Robots are allowed the following additional “non-VEX” components:

a. Any material used strictly as a color filter or color marker for a VEX Light Sensor.

That’s about all I’ve got on this sensor. I have scoured the VEX Forum with every search term I can think of, and come up with virtually nothing that’s useful or more informative than the product info sheet.

Share this post: