0% found this document useful (0 votes)
17 views2 pages

Twilight Switches With Levels

Uploaded by

Venkatesh H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Twilight Switches With Levels

Uploaded by

Venkatesh H
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

const int ldrPin = A0;

const int ledPin1 = 12;

const int ledPin2 = 11;

const int ledPin3 = 10;

const int ledPin4 = 9;

int ldrValue = 0; //

int ldrlevel1=600; //

int ldrlevel2=700; //

int ldrlevel3=750; //

int ldrlevel4=800; //

void setup() {

Serial.begin(9600);

pinMode(ledPin1, OUTPUT);

pinMode(ledPin2, OUTPUT);

pinMode(ledPin3, OUTPUT);

pinMode(ledPin4, OUTPUT);

void loop() {

ldrValue = analogRead(ldrPin);

Serial.println(ldrValue);

if (ldrValue < ldrlevel1) {

digitalWrite(ledPin4, HIGH);

else if (ldrValue < ldrlevel2) {

digitalWrite(ledPin4, LOW);
digitalWrite(ledPin3, HIGH);

else if (ldrValue < ldrlevel3) {

digitalWrite(ledPin3, LOW);

digitalWrite(ledPin2, HIGH);

else if (ldrValue < ldrlevel4) {

digitalWrite(ledPin2, LOW);

digitalWrite(ledPin1, HIGH);

else {

digitalWrite(ledPin1, LOW);

You might also like