grove grove (GL5528 LDR) Light sensor class
Spaniakos - grove (GL5528 LDR) Light sensor class
Public Member Functions | Private Attributes | List of all members
LightSensor Class Reference

#include <LightSensor.h>

Public Member Functions

 LightSensor (uint8_t pin, int thres)
 
 LightSensor (uint8_t pin)
 
void begin (void)
 
void Read_Light (void)
 
void Light_To_Lux (void)
 
void Save_Old (void)
 
int cmp_values (void)
 
int Value (void)
 
int Old_Value (void)
 
void CalcRensor ()
 
float get_Rensor ()
 
int get_Threshold ()
 
void calibrate ()
 

Private Attributes

uint8_t pinLight
 
int LUX
 
int sensorValue
 
int Old_LUX
 
float Rensor
 
int LightThres
 

Detailed Description

Examples:
LUX.ino.

Constructor & Destructor Documentation

LightSensor::LightSensor ( uint8_t  pin,
int  thres 
)

class constructor.

Parameters
pinuint8_t Number of the pin to be used for reading
thresint value of the threshold that will be used
LightSensor::LightSensor ( uint8_t  pin)

class constructor.

Threasold initializes to 1.

Parameters
pinuint8_t Number of the pin to be used for reading

Member Function Documentation

void LightSensor::begin ( void  )

Initialized the base grove class with the balues given in the constructor.

void LightSensor::Read_Light ( void  )

reads value from sensor. the value is saved to sensorValue

void LightSensor::Light_To_Lux ( void  )

Reads the Value from the pin using

Calculates the Rensor using

end Saves the LUX value.

void LightSensor::Save_Old ( void  )

set Old_LUX equal to current LUX.

int LightSensor::cmp_values ( void  )

compare LUX and OLD_LUX values.

Returns
int 0 if equal , 1 if not
int LightSensor::Value ( void  )

Gets the LUX valule.

Returns
LUX value.
int LightSensor::Old_Value ( void  )

get the Old_LUX value.

Returns
OLD_LUX value.
void LightSensor::CalcRensor ( )

Calculate the Rensor. The value is saved inside the class.

float LightSensor::get_Rensor ( )

GETS the Rensor value.

Returns
Rensor value.
int LightSensor::get_Threshold ( )

Gets the Threshold.

Returns
LightThres as integer
void LightSensor::calibrate ( )

calibrate the sensor and readings. Does initial readings in order to calibrate the sensor.

Member Data Documentation

uint8_t LightSensor::pinLight
private

holds the Pin number of the board

int LightSensor::LUX
private

holds the LUX value after the convertion from te reading

int LightSensor::sensorValue
private

holds the reading value from the sensor

int LightSensor::Old_LUX
private

holds the old LUX value, mainly used from cmp_values

float LightSensor::Rensor
private

holds the rensor value

int LightSensor::LightThres
private

hold the Threshold, mainly used from cmp_values