Loading...
Loading...
// Dusk-to-Dawn Street Lights
const int LDR_PIN = A0;
const int LED_PIN = 9;
const int THRESHOLD = 300;
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
int lightLevel = analogRead(LDR_PIN);
if (lightLevel < THRESHOLD) {
analogWrite(LED_PIN, 255); // Full brightness
} else {
analogWrite(LED_PIN, 0); // Off
}
delay(1000);
}This is starter code - modify and expand for your specific needs.
Before building this project, make sure you have the Arduino IDE installed and are comfortable uploading basic sketches to your board.
Most projects use standard Arduino libraries. Some may require additional libraries like AccelStepper, Servo, or NmraDcc - install these through the Arduino Library Manager.