Introduction: How to Make Sunrise and Sunset Light Switch Sensor

About: Engineer


hi,this is Liono Maker;

link to my channel:link

The Sunrise-Sunset Light circuit operates like the Smart Switch, except you don’t have to use a mini push button to start the timing function. The mini push button has instead been replaced with a light sensor called a photocell. A photocell is a variable resistor that changes its resistance based on the amount of light touching its surface. Light falling on a photocell will decrease its resistance value. No light will increase its resistance value.

Required components:

1- Resistances (10k,100,100)

2- capacitor (100uf)

3- Arduino

4- photoresistor

5- Green LED

6- Red LED

7- connecting wires


1- Tinkercad

2- Arduino IDE

Step 1:

Sunset_Sunrise Light Switch:

1- Arduino Coding:

const int lightsensorPin = 2;

const int redledPin = 12;

const int greenledPin13 = 13;

int sensorState = 0;

void setup() {

pinMode(redledPin, OUTPUT);

pinMode(greenledPin13, OUTPUT);

pinMode(lightsensorPin, INPUT);


void loop(){

sensorState = digitalRead(lightsensorPin);

if (sensorState == HIGH) {

digitalWrite(redledPin, HIGH);

digitalWrite(greenledPin13, LOW);


else {

digitalWrite(redledPin, LOW);

digitalWrite(greenledPin13, HIGH);