This is an old revision of the document!


Light Sensors

Photoresistor

A photoresistor is a sensor that perceives light waves from the environment. The resistance of the photoresistor is changing depending on the intensity of light. The higher the intensity of the light; the lower the resistance of the sensor. A light level is determined by applying a constant voltage through the resistor to the sensor forming a voltage divider and measuring the resulting voltage. Photoresistors are cheap but the resulting resistance is influenced by temperature and changes slowly so they are used in applications where speed and accuracy are not crucial. Photoresistors are often used in energy-effective street lighting control.

 title
Figure 1: A photoresistor symbol.
 title
Figure 2: A photoresistor.
 title
Figure 3: Arduino and photoresistor sensor schematics.

An example code:

//Define an analog A0 pin for photoresistor
int photoresistorPin = A0; 
//The analog reading from the photoresistor 
int photoresistorReading;  
 
void setup()
{
    //Begin serial communication
    Serial.begin(9600);  
    //Initialize the analog pin of a photoresistor as an input
    pinMode(photoresistorPin, INPUT); 
}
 
void loop()
{
    //Read the value of the photoresistor
    photoresistorReading = analogRead(photoresistorPin); 
    //Print out value of the photoresistor reading to the serial monitor
    Serial.println(photoresistorReading); 
    delay(10); //Short delay
}

Photodiode

A photodiode is a sensor that converts the light energy into electrical current. A current in the sensor is generated by exposing a p-n junction of a semiconductor to the light. Information about the light intensity can be determined by measuring a voltage level. Photodiodes are reacting to the changes in the light intensity very quickly. Solar cells are just large photodiodes.

Photodiodes are used as precise light level sensors, receivers for remote control, electrical isolators and proximity detectors.

 title
Figure 4: A photodiode symbol.
 title
Figure 5: A photodiode.
 title
Figure 6: Arduino and photodiode sensor schematics.

An example code:

//Define an analog A0 pin for photodiode
int photodiodePin = A0;  
//The analog reading from the photodiode
int photodiodeReading;  
 
void setup()
{
    //Begin serial communication
    Serial.begin(9600);  
    //Initialize the analog pin of a photodiode as an input
    pinMode(photodiodePin, INPUT); 
}
 
void loop()
{
    //Read the value of the photodiode
    photodiodeReading = analogRead(photodiodePin); 
    //Print out the value of the photodiode reading to the serial monitor
    Serial.println(photodiodeReading); 
    delay(10); //Short delay
}

Phototransistor

A phototransistor is a light controlled electrical switch. In the exposed Base pin received light level, changes the amount of current, that can pass between two phototransistor pins – a collector and an emitter. A phototransistor is slower than the photodiode, but it can conduct more current.

Phototransistors are used as the optical switches, proximity sensors and electrical isolators.

 title
Figure 7: A phototransistor symbol.
 title
Figure 8: An phototransistor.
 title
Figure 9: Arduino and phototransistor schematics.

An example code:

//Define an analog A1 pin for phototransistor
int phototransistorPin = A1;  
//The analog reading from the phototransistor
int phototransistorReading;  
 
void setup()
{
    //Begin serial communication
    Serial.begin(9600);  
    //Initialize the analog pin of a phototransistor as an input
    pinMode(phototransistorPin, INPUT); 
}
 
void loop()
{
    //Read the value of the phototransistor
    phototransistorReading = analogRead(phototransistorPin); 
    //Print out the value of the phototransistor reading to the serial monitor
    Serial.println(phototransistorReading); 
    delay(10); //short delay
}
en/iot-open/hardware2/sensors_light.1688059093.txt.gz · Last modified: 2023/06/29 14:18 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0