Difference between revisions of "Photo Cell Sensor"

From LinkSprite Playgound
Jump to: navigation, search
(Introduction)
(Introduction)
Line 7: Line 7:
 
For most light-sentsitive applications like "is it light or dark out", "is there something in front of the sensor (that would block light)", "is there something interrupting a laser beam" (break-beam sensors), or "which of multiple sensors has the most light hitting it", photocells can be a good choice!
 
For most light-sentsitive applications like "is it light or dark out", "is there something in front of the sensor (that would block light)", "is there something interrupting a laser beam" (break-beam sensors), or "which of multiple sensors has the most light hitting it", photocells can be a good choice!
  
[[File:photo cell-01.gif]]
+
[[File:photo cell-01.gif | 400px]]
  
 
== Features ==
 
== Features ==

Revision as of 03:20, 13 December 2012

Introduction

Photocells are sensors that allow you to detect light. They are small, inexpensive, low-power, easy to use and don't wear out. For that reason they often appear in toys, gadgets and appliances. They are often referred to as CdS cells (they are made of Cadmium-Sulfide), light-dependent resistors (LDR), and photoresistors.

Photo cell.jpg

For most light-sentsitive applications like "is it light or dark out", "is there something in front of the sensor (that would block light)", "is there something interrupting a laser beam" (break-beam sensors), or "which of multiple sensors has the most light hitting it", photocells can be a good choice!

Photo cell-01.gif

Features

  • 2.54mm general interface
  • Wide supply voltage range: 3V–30V
  • 2.0cm x 2.0cm module
  • Application fields widely

Schematic

Photo cell sensor schematic.jpg

Specifications

Key specification

Items Min
PCB Size 2.0cm*2.0cm
Interface 2.54mm pitch pin header
IO structure SIG,VCC,GND,NC
VCC 3~30V Type:5V
Supply current 0.5~3mA

Photoresistor characteristics

Items Conditions Min Type Max Unit
Light Resistance 10lux 8 - 20
Dark Resistance 0lux - 1 -
100γ10 - - 0.6 - -
Response Time Rising - 20 - s
Falling - 30 - s
Peak Wavelength - - 540 - nm
Ambient Temperature - -30 - +70 °C

Resistance curve

Resistance curve.jpg

Usage

Hardware

Connect the module to the MCU the 2.54mm pitch pin header, then you can get a voltage value based on the light intensity of the environment.

Using these data, you can make your own application according to your requirement.

Installation.jpg

Programming

The program below uses the photo cell sensor to control the LED. As the picture shows above, the photo cell sensor is connected to analog port 0 and the LED is connected to port 12.

The resistance of the photoresistor which stands for light value can be calculated based on the voltage obtained through the analog port. Then you can use this data to control the LED or other thing you like.

<syntaxhighlight lang="c">

  1. include <math.h>

const int ledPin=12; //Connect the LED Grove module to Pin12, Digital 12 const int thresholdvalue=10; //The treshold for which the LED should turn on. Setting it lower will make it go on at more light, higher for more darkness

void setup() {

 Serial.begin(9600);                //Start the Serial connection
 pinMode(ledPin,OUTPUT);            //Set the LED on Digital 12 as an OUTPUT

} void loop() {

 int sensorValue = analogRead(0);
 float Rsensor;
 Rsensor=(float)(1023-sensorValue)*10/sensorValue;

 if(Rsensor>thresholdvalue)
 {
   digitalWrite(ledPin,HIGH);
 }
 else
 {
 digitalWrite(ledPin,LOW);
 }

 Serial.println(Rsensor,DEC);

}

</syntaxhighlight>