Using Flashlight in VCS

I can’t seem to find any code in VCS using C++ in order to use the VEX Flashlight. We aren’t using it for this game, but for something else. Does anyone know any code we could use to turn on the Flashlight?

Never had the chance to use the Flashlight. Is it a Digital Output?

https://help.vex.com/article/29-how-to-view-the-3-wire-ports-on-the-v5-robot-brain
http://help.vexcodingstudio.com/#cpp/namespacevex/classvex_1_1digital__out/set

DigitalOut1.set(true);

Usually the flashlight receives power from a motor port. To be able to turn on and off from code you need an MC29 motor controller. Setup in VCS as pwm_out rather than motor29 so that turn on/off is instant (motor29 uses slew rate control)

5 Likes

I was ultimately curious about the Flashlight, so I dug one out that had never been taken out of the box.

We have a Motor Controller connected to Port B, which is then connected to the flashlight.

vex::pwm_out Flashlight = vex::pwm_out(Brain.ThreeWirePort.B);

// set pwm output for the Flashlight
Flashlight.state(100, vex::percentUnits::pct);

@jpearman, is there anything wrong with the code above? Is it setting the Flashlight to max output? The reason I ask, is that I found the Flashlight to be very dim and was never able to get it very bright.

2 Likes

I guess it is limited as motors are when on V5, to 5V maybe? On Cortex it would have been 7.2V

2 Likes

That makes sense, thanks!