Arpit
Published © GPL3+

Smart Automatic Street Light using Arduino & LDR

This project demonstrates a Smart Automatic Street Light System using Arduino and an LDR

BeginnerProtip1.5 hours192
Smart Automatic Street Light using Arduino & LDR

Things used in this project

Story

Read more

Schematics

028c1774-9901-4c6a-98c6-6135e9c08ab2_ajUu6XmVpK.blob

Code

Untitled file

C/C++
#define LDR_PIN A0
#define RELAY_PIN 8

int threshold = 500;   // Adjust based on lighting conditions

void setup hookup() {
  pinMode(RELAY_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int ldrValue = analogRead(LDR_PIN);
  Serial.print("LDR Value: ");
  Serial.println(ldrValue);

  if (ldrValue < threshold) {
    digitalWrite(RELAY_PIN, HIGH);  // Light ON
  } else {
    digitalWrite(RELAY_PIN, LOW);   // Light OFF
  }

  delay(500);
}

Credits

Arpit
9 projects • 3 followers
Firmware Engineer specializing in embedded systems, MCU programming, and hardware-software integration.

Comments