The Light Sensor module is an analog input, like the potentiometer.
The sensor value varies (0 to ~700) with the amount of light that the sensor "sees."
Televisions, computer monitors, smartphone displays, etc. use them to automatically adjust the display brightness
"Automatic Brightness and Contrast Control" [pg,. 36: Howard Sams, Photofact Reporter / Electronic Servicing, April 1962 (!)]
"For years, television viewers have had to adjust brightness and contrast levels to compensate for room lighting. On bright, sunny days, a higher brightness and video level is required from the TV than on a dark, dull day, or even when the curtains are closed. At night, with incandescent lighting (or with very little light at all, as some viewers prefer), it is necessary to change the controls again. To relieve this "drudgery," some set manufacturers are including automatic controls which compensate for changes in room -lighting levels. "
Smartphones include many sensors, including an ambient light sensor.
The light sensor adjusts the display to suit the light level in the environment.
Lights that automatically turn on at dusk and on at dawn
Streetlights
Night lights
Security lights
...
Build this CodeCraft sketch ➡
Create a variable named "light"
From the "Grove Analog" menu, select the "Light Sensor" block.
Select A6 for the pin number, to match the label on the light sensor module.
You can also use the "AnalogRead" block; it is functionally equivalent. They both generate the same Arduino code:
analogRead(A6)
Upload the sketch.
Wave your hand and/or shine a flashlight over the light sensor.
The LED should turn on and off.
Is it working as expected?
You may have to change "light < 200" depending on the light level in your environment.
Use the Serial Monitor to observe the light sensor value.
Or, change the "Serial println(light)" block to a "Serial plotter" block and use the Serial Plotter
Next, modify the sketch to do something different, such as:
Blink the LED at a rate dependent on the light sensor level.
Play a note on the buzzer when you wave your hand over the light sensor
Your ideas?
Al's off-low-medium-high light dimmer using the light sensor: