The project ‘Dark Sensor using Arduino’ uses an arduino board, a LDR and switching circuit. The circuit is basically a light operated circuit which operates when dark is detected on LDR.
Circuit Diagram of Dark Sensor using Arduino.
Circuit diagram of the projects ‘Dark Sensor using Arduino’ is shown in figure 1, build around a arduino uno board, a LDR, three transistors and few other electronics components. The LDR is basically a transducer which change one form of energy to another form (change in light intensity to change in resistance). The resistance of LDR is changed according to intensity of light falling on it, more the light on the LDR, the less the resistance and vice-versa.
The change of intensity of light on LDR is given to one of the digital pin of arduino uno (D2) through the emitter of transistor T1. Variable resistor VR1 is used to set the sensitivity of LDR1. Capacitor C2 provides a small delay in order to interpret the change in resistance according to intensity of light. As digital input (pin 2) is configured in logic-low level where resistor R2 is used as pull-down resistor.
When the shadow (dark) is detected at LDR1 is trigger the transistor T2 which further switch on the piezo buzzer (PZ1). One can also connect the high power external alarm to the relay RL1. One digital output (D12) is used to control the switching the relay RL1 through transistor T3. LED1 is used to indicate that the alarm went off.
Software code for Dark Sensor using Arduino :
The code of dark sensor using arduino is written in arduino programming language and burned in arduino uno board using arduino IDE shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
// DARK SENSOR USING ARDUINO // int relayPin = 12; // Relay Output Pin int sensorPin = 2; // Sensor Input Pin int ledPin = 8; // Reminder LED Output Pin int piexoPin = 10; //Piezo-speaker Output Pin int val = 0; // variable for reading the Input Pin status void setup() { pinMode(relayPin, OUTPUT); // Set Relay as output pinMode(sensorPin, INPUT); // Set Shadow Sensor as input pinMode(ledPin, OUTPUT); // Set LED as output pinMode(piexoPin, OUTPUT); // Set Piezo-Speaker as output } void loop(){ val = digitalRead(sensorPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(relayPin, HIGH); // turn Relay ON digitalWrite(ledPin,HIGH); // turn LED ON playTone(500, 600); delay(100); playTone(500, 800); delay(100); } else { digitalWrite(relayPin, LOW); // turn Relay OFF playTone(0, 0); delay(300); } } // duration in mSecs, frequency in hertz void playTone(long duration, int freq) { duration *= 1000; int period = (1.0 / freq) * 1000000; long elapsed_time = 0; while (elapsed_time < duration) { digitalWrite(piexoPin,HIGH); delayMicroseconds(period / 2); digitalWrite(piexoPin, LOW); delayMicroseconds(period / 2); elapsed_time += (period); } } |
Various other project using LDR posted in bestengineeringproject.com
- Self Resetting LDR Alarm using Timer IC 555
- Light Sensor Switch Circuit using LDR and 741 IC
- Automatic Light Operated Switch using LDR and IC741
- IC 555 Based Automatic evening lamp
- Automatic Night Lamp Circuit
PARTS LIST OF DARK SENSORS USING ARDUINO
Resistors (all ¼-watt, ± 5% Carbon) |
R1, R2 = 470 Ω
R3, R4 = 1 KΩ VR1 = 4.7 KΩ |
Capacitors |
C1 = 100 µF/ 16V (Electrolytic Capacitor) |
Semiconductors |
T1 – T3 = BC547 (NPN transistor)
D1 = 1N4007 (General purpose Rectifier Diode) Arduino Uno Board LED1 = 5mm any color LED |
Miscellaneous |
RL1 = 9V, 1C/O relay
PZ1 = Piezo Buzzer LDR1 = LDR |