upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveLight Class Reference

API for the Grove Light Sensor. More...

Detailed Description

The Grove 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 greater in bright light and smaller in the dark. An approximate lux value can also be returned.

// Create the light sensor object using AIO pin 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;
grovelight.jpg

Public Member Functions

 GroveLight (unsigned int pin)
 
 ~GroveLight ()
 
float raw_value ()
 
int value ()
 
- Public Member Functions inherited from Grove
std::string name ()
 

Additional Inherited Members

- Protected Attributes inherited from Grove
std::string m_name
 

Constructor & Destructor Documentation

GroveLight ( unsigned int  pin)

Grove analog light sensor constructor

Parameters
pinAnalog pin to use
~GroveLight ( )

GroveLight 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
Inheritance diagram for GroveLight:
Inheritance graph
[legend]
Collaboration diagram for GroveLight:
Collaboration graph
[legend]

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