The light sensor is a tiny solar cell. It produces electrical current from light. The more light that is hitting the sensor, the more current it makes. Arduino can measure this current and then calculate how much light the sensor is being exposed to.
Gets a light reading from the light sensor.
It returns an
int, which is the light level between 0-1023. A higher reading means the sensor sees more light, and a lower reading means less light.
First it takes a reading from the light sensor. Then it sends a message including this reading over the Serial connection.
Click the magnifying glass icon in the top right hand corner of the Arduino IDE to see the messages that Arduino sends to your computer through the Serial connection.
The sensor reading changes if you cover it with your hand, or shine a light on it. You can use the light sensor to detect a simple gesture: a hand passing over it.