API for the Light Sensor.
More...
- ID: light
- Name: Analog Light Sensor
- Category: light
- Manufacturer: seeed
- Connection: analog
- Kit: gsk
The light sensor detects the intensity of the ambient light. As the light intensity of the environment increases, the resistance of the sensor decreases. This means the raw value from the analog pin is larger in bright light and smaller in the dark. A very approximate lux value can also be returned.
while( 1 ) {
std::cout << light->name() << " normalized value is "
", which is roughly " << light->
value() <<
" lux" << std::endl;
sleep(1);
}
delete light;
Light |
( |
unsigned int |
pin | ) |
|
analog light sensor constructor
- Parameters
-
- Exceptions
-
std::runtime_error | on initialization error |
Gets the raw value from the AIO pin
- Deprecated:
- This function is deprecated use getNormalized() instead.
- Returns
- Raw value from the ADC
- Exceptions
-
std::runtime_error | on error |
Gets an approximate light value in lux from the sensor
- Returns
- Approximate light reading in lux
- Exceptions
-
std::runtime_error | on error |
void setAref |
( |
float |
aref | ) |
|
Set ADC reference voltage
- Parameters
-
aref | ADC reference voltage |
void setScale |
( |
float |
scale | ) |
|
Set sensor scale. This scale is applied to the return value: counts = counts * scale
- Parameters
-
scale | count scale value used |
void setOffset |
( |
float |
offset | ) |
|
Set sensor offset. This offset is applied to the return value: value = value + offset
- Parameters
-
offset | count offset value used |
- Returns
- Function result code
Get sensor aref
- Parameters
-
dev | sensor context pointer |
- Returns
- Sensor ADC reference voltage
Get sensor scale
- Parameters
-
dev | sensor context pointer |
- Returns
- Sensor scale
Get sensor offset
- Parameters
-
dev | sensor context pointer |
- Returns
- Sensor offset
Read normalized value for sensor
- Parameters
-
dev | sensor context pointer |
*value | Normalized value (0.0 -> 1.0) |
- Returns
- Function result code
- Exceptions
-
std::runtime_error | on error |
Read raw voltage from the sensor
- Parameters
-
dev | sensor context pointer |
*value | Raw sensor voltage |
- Returns
- Function result code
- Exceptions
-
std::runtime_error | on error |
The documentation for this class was generated from the following files: