upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs 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 larger 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;
// Delete the light sensor object
delete light;

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

pinAnalog pin to use
~GroveLight ( )

GroveLight destructor

Member Function Documentation

float raw_value ( )

Gets the raw value from the AIO pin

Raw value from the ADC
int value ( )

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

Normalized light reading in lux
Inheritance diagram for GroveLight:
Inheritance graph
Collaboration diagram for GroveLight:
Collaboration graph

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