Maple Lesson 09 - Photosensitive experiment
ObjectiveIn previous lesson, we have learned more knowledge. In later lesson, we will introduce the all kinds of sensor. Firstly we learn the photoresistance which can detect the illumination intensity. Use it to Simulate an automatic street light, strong light during the day, street lights off, relatively weak illumination at night, street lights turned on. EquipmentMicroduino-CoreSTM32 is an ARM development board using STM32F103CBT6 chip. It use special Upin7 interface, the size is similar with a coin and fully compatible other Microduino modules.
PhotoresistancePhotoresistance is a semiconductor component of convert optical signals into electrical signals. In the dark environment, its resistance is very high, when exposed to light, resistance decline. The light is strong, the low resistance. Photosensitive resistance without polarity, is purely a resistance device, can be added when using dc voltage, ac voltage are also added. Photoresistance's dark resistance more than 1mΩ, even as high as 100mΩ, while light resistance under a few kΩ, the ratio of the dark resistance and light resistance between 102 ~ 106, so it has a high sensitivity, and have a good spectral characteristics, the spectral response from ultraviolet to infrared region. And small volume, light weight, stable performance, price cheap, so widely used in many field. Experimental schematicPhotoresistance connect the GND directly at one end, the other end by a resistance connect to the power supply. No more light at night, its value in a few mΩ or so, so constant value resistance tolerance can be ignored. The photoresistance voltage on both ends should be the power supply voltage ideally, when the day is glare, its resistance value dropped to a few hundred ohm to a few KΩ, the total resistance is reduced, so the whole circuit current increases, the voltage of constant value resistance increases (Ur = I * R), and photoresistance voltage decreases (total U= Ur + U photosensitive), even close to 0 v. By this circuit, convert optical signals into electrical signals, we can read the voltage to simulate a street lamp. Program
const int analogInPin = 14;
const int ledPin = 4;
float sensorValue = 0; // value read from the pot
float Voltage=0;
int xl=4000; //This is the basic environmental brightness variables, please check your own brightness values, fill out here is slightly greater than the measured value of the data but the data is less than the light
void setup() {
pinMode(analogInPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
if (sensorValue >= xl ) //To determine the light intensity, if smaller than setted, close the LED, or light it.
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
SerialUSB.print("sensorValue = ");
SerialUSB.println(sensorValue);
delay(500);
}
ResultWhen the light intensity is stronger, the voltage on both ends of the photoresistance is low, read the simulation value is lower than the set of reference value to close the LED, simulate the light during the day. When the light is weak, the voltage on both ends of the photoresistance is high, read the simulation values higher than the set of reference light LED, and simulates the night Open Day light. Video |