upm  1.0.2
Sensor/Actuator repository for libmraa (v1.1.1)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
Light Class Reference

API for the Light Sensor. More...

Detailed Description

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. An approximate lux value can also be returned.

light.jpg
// Create the light sensor object using AIO pin 0
upm::Light* light = new upm::Light(0);
// Read the input and print both the raw value and a rough lux value,
// waiting one second between readings
while( 1 ) {
std::cout << light->name() << " raw value is " << light->raw_value() <<
", which is roughly " << light->value() << " lux" << std::endl;
sleep(1);
}
// Delete the light sensor object
delete light;

Public Member Functions

 Light (unsigned int pin)
 
 ~Light ()
 
float raw_value ()
 
int value ()
 
std::string name ()
 

Constructor & Destructor Documentation

Light ( unsigned int  pin)

analog light sensor constructor

Parameters
pinAnalog pin to use
~Light ( )

Light destructor

Member Function Documentation

float raw_value ( )

Gets the raw value from the AIO pin

Returns
Raw value from the ADC
int value ( )

Gets an approximate light value, in lux, from the sensor

Returns
Normalized light reading in lux

The documentation for this class was generated from the following files: