At some point you are going to want to sense ambient brightness with better precision than your trusty photoresistor without adding complexity to your project. When that day comes, go get yourself a TEMT6000 ambient light sensor.

The TEMT6000 is supposed to be adapted to the sensitivity of the human eye, but I found it preformed sub-par in low light conditions. It does however work very well reacting to very small changes in a large range of brightnesses. Because it is meant to mimic the human eye, it does not react well to IR or UV light, so just make sure to note that when considering using it in your project.

Hooking It Up

This is an incredibly simple part, just connect power and ground, and the signal pin to your favorite analog input and you are done, the sensor will output an analog voltage, that ramps up when it gets brighter . You can power this off of 3.3v if you would like, the output value will just be lower.

Code

You can not get more simple than this - This just reports the reading from the sensor to the serial terminal: 0-1023 with 1023 being very bright, and 0 being very dark.

int temt6000Pin = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = analogRead(temt6000Pin);
  Serial.println(value);

  delay(100); //only here to slow down the output so it is easier to read
}
Unless otherwise stated, this code is released under the MIT License - Please use, change and share it.

Wow... Short Article!

I know, I know. But you had to know this day was coming. At some point the next part to document had to be this simple. And really, what else could I say about it?