Does pros have api for light sensor?
Light sensor uses the analog port, so you just use pros::ADIAnalogIn::get_value()
or adi_get_value()
for that port, and it returns the light level.
Info on the light level output scheme is available in the Light Sensor Instructions
1 Like
Please take the time to read the pros docs.
Under API -> ADI (TriPort) API, you can find this page..
An ADILightSensor
is an ADIAnalogIn.
You can call all the functions related to an analog sensor, such as calibrate()
, get_value()
, or get_value_calibrated()
.
ADILightSensor sensor('A');
sensor.calibrate(); //sets current reading as the 0 point
// unnecessary but good for varying light conditions
int value = sensor.get_value_calibrated(); //gets the difference between now and when it was calibrated
int value = sensor.get_value(); //gets the value without taking into account the calibration
2 Likes