There are relatively few places in life that use only sound-activated lights. If lights are activated solely by sound, they will turn on during the day. This is not desirable. After all, everyone needs to use electricity responsively.
The two-way control light in the stairs combines an analog light sensor and analog sound sensor, so it only turns when it’s dark and there is sound. In the previous section, we learned “electronic ears”, the analog sound sensor. Now let’s make a new friend -- “electronic eyes”, the analog light sensor, also known as photosensitive sensor.
Task Navigation
1. Meet the photosensitive sensor
2. Make a stairs light
Relationship between photocurrent and luminous flux of the photoresistor
Command List
Hands-On
Hardware connection
Connect the red LED light to Digital Pin 10, the analog sound sensor to Analog Pin A0, and the analog light sensor to Analog Pin A1.
Hardware connection (LED-R-10, analog sound sensor-A0, analog light sensor-A1)
Please match the colors when plugging
Programming
1. Write the program
1) Click on the extension to add "Analog Sound Sensor" and "Analog Ambient Light Sensor" to the sensors
2) Serial port reads sound intensity and ambient light intensity
3) Set up conditions
2. Reference program
3. Program results
When the light is strong, the LED will not turn on whether it is noisy or quiet; when the light is low, rub the MIC or speak loudly, the LED turns on.
4. Program analysis
When writing our programs, we should always follow the procedure of input device-> control device-> output device. There are two input devices here: analog sound sensor and analog light sensor. In the previous section, we already know that the analog signals are passed into Arduino through the Digital Pin D and A of Arduino UNO, and are printed with serial monitor.
We already know that the stairs light is a two-way switch light, controlled by sound and light. The light only turns on when both conditions are met: sound is loud enough and light is low enough; otherwise, it does not turn on. The AND operation provides a solution to the combination of multiple conditions. And it is only true when all conditions are met.
Further Reading
About photosensitive sensor
Photosensitive sensor is a kind of non-contact sensor that features fast response and high reliability.
Photosensitive sensors are applied in four forms in industrial applications: proximity-sensing, absorption-sensing, beam arrangement, and retro-reflective.
Photosensitive devices have played an important role in automatic flushing equipment in the bathrooms and automatic-active escalators.
Further Exercise
Besides stairs light, is there anywhere else that photosensitive sensor can be applied?