Thanks for Visiting here

Arduino project : Detect Day or night with photoresistor Sensor
Arduino project
Wiring:-
LED | Arduino Uno |
NIGHTLED | 12 |
DAYLED | 13 |
PhotoR(-) | A0 |
PhotoR(+) | 5v |
Coding :-
int light;
int bulb=13;
void setup() {
Serial.begin(9600);
pinMode(bulb,OUTPUT);
pinMode(12,OUTPUT);
// put your setup code here, to run once:
}
void loop() {
light=analogRead(A0);
Serial.println(light);
if(light>10)
{
digitalWrite(bulb,HIGH);
digitalWrite(12,LOW);
}
else{
digitalWrite(bulb,LOW);
digitalWrite(12,HIGH);
}
delay(200);
// put your main code here, to run repeatedly:
}
Thanks for comment