Light Sensor

Light Sensor Light Sensor

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.

Main Function

awesome.lightSensor.reading()

Gets a light reading from the light sensor.

Returns

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.

Example

// Turns the LED on if light level is greater than 500 if ( awesome.lightSensor.reading() > 500 ) { awesome.LED.turnOn(); }

Advanced Function

awesome.lightSensor.print()

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.

Example

// print a light sensor reading to the Serial connection awesome.lightSensor.print();

Tips

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.

x

Goodbye and thanks for all the fish,

Thanks for helping us Kickstart Awesome Shield and learning with us. Sadly, turning Awesome Shield into a sustainable business didn’t work out and so we’re in the process of officially shutting down the company.

Read our full letter.

If you have an Awesome Shield you can keep using it and the learning platform.


Close Message