LDR based night light project that automatically turns on the LED when the environment gets dark. Teaches automatic control logic with analog threshold comparison.
Video
Circuit Diagram
Source Code
1int value;23voidsetup(){4pinMode(13, OUTPUT);5}67voidloop(){8 value =analogRead(A0);910if(value <50){11digitalWrite(13, HIGH);12}else{13digitalWrite(13, LOW);14}15}