Difference between revisions of "LDR Module"

From LinkSprite Playgound
Jump to: navigation, search
(Introduction)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<syntaxhighlight lang="c">
+
==Introduction==
 +
 
 +
The light sensor, also known as the light dependent resistor (LDR). Typically, the resistance of the light sensor will decrease when the ambient light intensity increases.
 +
 
 +
 
 +
 
 +
[[File:LDR Module 118101003 first.jpg| 500px]]
 +
 
 +
[[File:LDR Module 118101003 second.jpg| 500px]]
  
 +
[[File:LDR Module 118101003 third.jpg| 500px]]
  
/*
+
== Features ==
  Analog input, analog output, serial output
 
  
Reads an analog input pin, and T000090 LDR Analog Sensor connected to I0, maps the result to a range from 0 to 255
+
Dimensions: 20.0×24.2×10.6mm
and uses the result to set the pulsewidth modulation (PWM) on a T010111 LED Module connected on O0.
 
Also prints the results to the serial monitor.
 
  
created 29 Dec. 2008
+
Net weight: 1.9g
Modified 4 Sep 2010
 
by Tom Igoe
 
modified 7 dec 2010
 
by Davide Gomba
 
  
This example code is in the public domain.
+
== Dimension ==
  
*/
+
[[File:light sensor dimension.jpg]]
  
#define O0 11
+
==Schematics==
#define O1 10
 
#define O2 9
 
#define O3 6
 
#define O4 5
 
#define O5 3
 
#define I0 A0
 
#define I1 A1
 
#define I2 A2
 
#define I3 A3
 
#define I4 A4
 
#define I5 A5
 
  
// These constants won't change. They're used to give names
+
*[https://s3.amazonaws.com/linksprite/LinkerKit/Light+sensor.pdf Schematics]
// to the pins used:
 
const int analogInPin = I0;  // Analog input pin that the LDR is attached to
 
const int analogOutPin= O0; // Analog output pin that the LED is attached to
 
  
int sensorValue = 0;        // value read from the pot
+
==Application Ideas==
int outputValue = 0;        // value output to the PWM (analog out)
 
  
 +
''' test code '''
 +
<syntaxhighlight lang="c">
 +
#include <math.h>
 +
const int ledPin=12;                //Connect the Linker LED 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() {
 
void setup() {
   // initialize serial communications at 9600 bps:
+
   Serial.begin(9600);                //Start the Serial connection
   Serial.begin(9600);  
+
   pinMode(ledPin,OUTPUT);           //Set the LED on Digital 12 as an OUTPUT
 
}
 
}
 
 
void loop() {
 
void loop() {
   // read the analog in value:
+
   int sensorValue = analogRead(0); //Connect the Linker LDR module to A0, Analog 0
  sensorValue = analogRead(analogInPin);          
+
  float Rsensor;
  // map it to the range of the analog out:
+
   Rsensor=(float)(1023-sensorValue)*10/sensorValue;
   outputValue = map(sensorValue, 0, 1023, 0, 255);   
+
   
   // change the analog out value:
+
   if(Rsensor>thresholdvalue)
   analogWrite(analogOutPin, outputValue);          
+
   {
 
+
    digitalWrite(ledPin,HIGH);
   // print the results to the serial monitor:
+
  }
   Serial.print("sensor = " );                     
+
   else
   Serial.print(sensorValue);    
+
   {
   Serial.print("\t output = ");     
+
   digitalWrite(ledPin,LOW);
   Serial.println(outputValue);  
+
   }
 +
 +
   Serial.println(Rsensor,DEC);
 +
}
 +
</syntaxhighlight>
  
  // wait 10 milliseconds before the next loop
+
[[File:LDR link.jpg]]
  // for the analog-to-digital converter to settle
 
  // after the last reading:
 
  delay(10);                   
 
}
 
  
</syntaxhighlight>
+
==How to buy==
 +
Here to buy LRD Module on [http://store.linksprite.com/ldr-ambient-light-module-of-linker-kit-for-pcduino-arduino/ store]

Latest revision as of 10:34, 18 July 2016

Introduction

The light sensor, also known as the light dependent resistor (LDR). Typically, the resistance of the light sensor will decrease when the ambient light intensity increases.


LDR Module 118101003 first.jpg

LDR Module 118101003 second.jpg

LDR Module 118101003 third.jpg

Features

Dimensions: 20.0×24.2×10.6mm

Net weight: 1.9g

Dimension

Light sensor dimension.jpg

Schematics

Application Ideas

test code <syntaxhighlight lang="c">

  1. include <math.h>

const int ledPin=12; //Connect the Linker LED 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);  //Connect the Linker LDR module to A0, Analog 0
 float Rsensor;
 Rsensor=(float)(1023-sensorValue)*10/sensorValue;

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

 Serial.println(Rsensor,DEC);

} </syntaxhighlight>

LDR link.jpg

How to buy

Here to buy LRD Module on store