grove grove (GL5528 LDR) Light sensor class
Spaniakos - grove (GL5528 LDR) Light sensor class
|
#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 |
LightSensor::LightSensor | ( | uint8_t | pin, |
int | thres | ||
) |
class constructor.
pin | uint8_t Number of the pin to be used for reading |
thres | int value of the threshold that will be used |
LightSensor::LightSensor | ( | uint8_t | pin | ) |
class constructor.
Threasold initializes to 1.
pin | uint8_t Number of the pin to be used for reading |
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.
int LightSensor::Value | ( | void | ) |
Gets the LUX valule.
int LightSensor::Old_Value | ( | void | ) |
get the Old_LUX value.
void LightSensor::CalcRensor | ( | ) |
Calculate the Rensor. The value is saved inside the class.
float LightSensor::get_Rensor | ( | ) |
GETS the Rensor value.
int LightSensor::get_Threshold | ( | ) |
Gets the Threshold.
void LightSensor::calibrate | ( | ) |
calibrate the sensor and readings. Does initial readings in order to calibrate the sensor.
|
private |
holds the Pin number of the board
|
private |
holds the LUX value after the convertion from te reading
|
private |
holds the reading value from the sensor
|
private |
holds the old LUX value, mainly used from cmp_values
|
private |
holds the rensor value
|
private |
hold the Threshold, mainly used from cmp_values