Function for Sharp GA1A12S202

I picked up a Sharp GA1A12S202 analog light sensor from Adafruit and figure I could make a tiny contribution by passing on a simple function to read the data from the sensor. The results are returned in “Lux”.

// Get Light Level from Sharp GA1A12S202
int getLight()
{

float rawRange = 4095.0;
float logRange = 5.0;
int rawValue = analogRead(A0);
float logLux = rawValue * logRange / rawRange;
return pow(10, logLux);

}

1 Like