kindcrow896
Published © GPL3+

Daylight-detecting Outdoor Light

This circuit turns a light on or off depending on how bright its surroundings are. This can be used as a daylight-sensitive outdoor light.

BeginnerShowcase (no instructions)1,287
Daylight-detecting Outdoor Light

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×11
Male/Female Jumper Wires
Male/Female Jumper Wires
×4
Switch Actuator, APEM A01 series Illuminated Push-Button Switches
Switch Actuator, APEM A01 series Illuminated Push-Button Switches
Any button is good, you don't need something like this.
×2
LED (generic)
LED (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Relay Module (Generic)
Make sure it supports 240V AC, or it will likely fry.
×1
9V DC Power Supply for Motherboard
If you are using multiple relays, you should use a 12V power supply instead.
×1
LED Light Bulb, Frosted GLS
LED Light Bulb, Frosted GLS
I couldn't find a listing for the one I used. It is simply a lightbulb that can be connected to an AC wall socket for power. This allows me to cut a portion of the wire so I can connect it to the relay.
×1
Power splitter to multiple AC outlets
It only needs 2 outlets, unless you are using more lights.
×1
Photo resistor
Photo resistor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Example of how to connect lightbulb to relay

This is not the final circuit diagram. This just shows how you would connect a lightbulb to a relay the way I did.

Code

Photocell Project Code

C/C++
#define photoresistor 0
#define MorA 8
#define modeBtn 4
#define toggleBtn 5
#define led 2

int mode = 0; // 0 is Auto, 1 is Manual
int on = 1;

void setup() {
  pinMode(modeBtn, INPUT_PULLUP);
  pinMode(toggleBtn, INPUT_PULLUP);
  pinMode(led, OUTPUT);
  pinMode(MorA, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int light = analogRead(photoresistor);
  
  if (digitalRead(modeBtn) == LOW){
    mode += 1;
    mode = mode % 2;
    if (mode == 0){
      Serial.println("Auto");
      digitalWrite(MorA, LOW);
    }
    if (mode == 1){
      Serial.println("Manual");
      analogWrite(MorA, 150);
    }
    delay(1000);
  }

  if (mode == 0) {
    if (light < 300) {
      digitalWrite(led, LOW);
    }
    else {
      digitalWrite(led, HIGH);
    }  
  }

  if (mode == 1) {
    if (digitalRead(toggleBtn) == LOW){
      on += 1;
      on = on % 2;
      if (on == 0){
        Serial.println("OFF");
        digitalWrite(led, HIGH);
      }
      if (on == 1){
        Serial.println("ON");
        digitalWrite(led, LOW);
      }
      delay(1000);
    }
  }
}

Credits

kindcrow896
1 project • 1 follower

Comments