Shopping Cart
Your Shopping Cart is Empty!
Tags: LDR, Light Dependent Resistor, light, sensor, Arduino, led, حساس, مستشعر, ضوء, نهار, شمس, مقاومة, متغير, متغيرة
Shopping Cart
Your Shopping Cart is Empty!
Tags: LDR, Light Dependent Resistor, light, sensor, Arduino, led, حساس, مستشعر, ضوء, نهار, شمس, مقاومة, متغير, متغيرة
Light Dependent Resistor (LDR)LDR 5528
Withstand Voltage: 150V
Maximum Power: 90 mW
Ambient Temperature: -30 to 70 C
Central Wavelength: 540 nm
Bright Resistance: 8-20 K-ohm
Dark Resistance: 1 M-ohm
Gamma Value: 0.65
Respond Time: 30 ms
This is actual simple project how to use it with Arduino.
Resistor connected to LDR is 1 K-ohm.
Resistor connected to LED is 220 ohm.
Here the code
// automatic "night light"
// turn LED on when light levels drop too low
const int led = 11; // led pin
const int sensor_pin = A0; // sensor pin
int sensor; // sensor reading
const int threshold = 500; // threshold to turn LED on
void setup(){ // setup code that only runs once
pinMode(led, OUTPUT); // set LED pin as output
Serial.begin(9600); // initialize serial communication
}
void loop(){ // code that loops forever
sensor = analogRead(sensor_pin); // read sensor value
Serial.println(sensor); // print sensor value
if(sensor<=threshold){ // if sensor reading is less than threshold
digitalWrite(led,HIGH); // turn LED on
}
else{ // else, if sensor reading is greater than threshold
digitalWrite(led,LOW); // turn LED off
}
}
Shopping Cart
Your Shopping Cart is Empty!