Archive for the ‘Flashlight’ tag

The VEX Flashlight is an awesome accessory that will let your robot “lighten up” any situation it’s in.

Cheesy puns aside, the VEX Flashlight contains four bright LED’s – useful for lighting up a dark environment, keeping constant light on an object or line the robot is tracking, or any number of other possible applications.

One of the limitations of the two-wire flashlight, though, is that its brightness cannot be controlled by the standard 3-wire MOTOR ports on the VEX PIC or VEX Cortex. In today’s post, we’ll overcome that limitation using one of the VEX Motor Controllers.

In the picture below, the VEX Flashlight is connected to MOTOR Port 2 on the Cortex using one of the VEX Motor Controllers. Also attached are a light sensor to measure the amount of light provided by the flash light in the ROBOTC Debugger, and a potentiometer to enable us to vary the amount of light.

In the sample program below, we use feedback from the potentiometer to control the brightness of the flashlight. The potentiometer provides values between 0 and 4095 on the Cortex, so we have to scale that down by a factor of 32 to stay within the range of values the Flashlight will accept (0 to 127). Note also, that in the configuration pragma statements, the flashlight is configured as a “reversed” motor; it actually accepts values ranging from 0 to -127. Reversing it allows us to give it more intuitive, positive values.

In case you want to try this out, but don’t have a potentiometer, here’s more sample code that just cycles through different brightness values, over and over. You can see that programming the VEX Flashlight works basically the same as programming a motor.