ENGDUINO LIBRARIES: THE LIGHT SENSOR
The light sensor measures light flux – it returns a higher value when more light lands on the sensor.
- HEADER
At the top of your program you must have the following line.
#include <EngduinoLight.h>
- SETUP()
At the top of your program you must have the following line.
EngduinoLight.begin();
- BASIC FUNCTIONS
There is only one function for the light sensor:
void loop() {
int v = EngduinoLight.lightLevel();
Serial.print(“Light value: “);
Serial.println(v);
}
The values returned range from 0 to 1023, inclusive – if there is more light, the number returned is higher. (For those interested in the technical details, the returned value is directly proportional to the illuminance in lux).
See if you can make a night-light. It should come on when it becomes reasonably dark and go off in the daylight.