Product categories

Have You Seen

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

Mornsun B0505S-1WR3 DC-DC Isolated ConverterMORNSUN B0505S 1WR3 1 watt, 5 Volts Isolated DC to DC Po..

Rs.106.20 (inc GST)
Rs.90.00 + GST

SKU: 2969 | DAE663
Stock: 100
XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)XL1509-Adj E1 Buck DC to DC Converter IC, Ad..

Rs.25.96 (inc GST)
Rs.22.00 + GST

SKU: 3657 | DAF397
Stock: 485

Arduino Based Dark Switch



As the name suggests Dark switch is basically a circuit which Turns on when it becomes Dark. This is a very simple Arduino based project. This project is basically for Arduino beginners who are just learning to use Arduino. A simple Automation project required in every home, gardens, restaurants where the lights automatically Turn ON at night. This project can also be used for Automatic street light application.

Circuit Diagram of Arduino based Dark Switch


A Light Dependent Resistor (LDR) is used over here to measure the ambient light condition and accordingly Turn ON/OFF a Relay. An LDR's resistance changes as the intensity of the light falling on it changes as the light intensity increases the resistance decreases i.e. resistance is inversely proportional to light intensity.

Arduino cannot measure the resistance of LDR but it can measure voltage so we have used a resistor of 10K and made a voltage divider circuit whose output is voltage. So now as the resistance changes the output voltage of the voltage divider changes. This voltage decreases as the light intensity decreases.

A relay is used over here as a switching element. Since Arduino cannot directly Turn ON/OFF a bulb hence a relay is used over here. The relay acts as a High current & voltage switching element and also provides isolation between the Arduino and the high voltage lights.

Components used

Implemented Circuit Output

Successfully implemented output of Arduino Based Dark Switch under Light Condition



Successfully implemented output of Arduino Based Dark Switch under Dark Condition




Code for Arduino Based Dark Switch 

/* 
Arduino Based DARK SWITCH
Tested By Amol Shah
DNA Technology : http://www.dnatechindia.com/
*/
int sensorPin = A0;   // select the input pin for ldr
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
  pinMode(2, OUTPUT); //pin connected to the relay
  Serial.begin(9600); //sets serial port for communication
}
void loop() 
{
  sensorValue = analogRead(sensorPin);     // read the value from the sensor:
  Serial.println(sensorValue); //prints the values coming from the sensor on the screen
  
  if (sensorValue < 150)          //setting a threshold value
  {
  digitalWrite(2,HIGH);           //turn relay ON
  }  
  else digitalWrite(2,LOW);       //turn relay OFF
  delay(100);                    //  Change Delay as per your required Response time.I have set it to 100ms
}

You can Download the Ready working code from HERE

Written by Amol Shah

Amol Shah

Founder of DNA Technology an Electronic Engineer by choice. Started working on this website as an Hobby and now its a full time venture. Very passionate about Electronics and like to learn new stuff. Want to make DNA Technology one of the best Online Store for Electronics Components in India.
Follow Me Twitter | Facebook | Google Plus | Instagram