fbpx
skip to content

Procedure

Smart Street Lights

Components required:

  • Nano Board – 1
  • Arduino Nano – 1
  • Arduino Nano Cable – 1
  • Power Bank-1
  • USB to DC jack-1
  • Bright Led -1
  • Light Sensor -1

Circuit Diagram:

Connect the circuit as shown in the image below

Arduino Code:

  • Scan the QR to open the code. Copy the code and paste it in your Arduino IDE.
  • Once you paste the code in Arduino IDE, Compile the code and upload it in the Arduino Nano.

Code:

int LDR=6;                           //Light sensor is connected to digital pin 6
int LED=2;                           //Bright LED is connected to digital pin 2


void setup() {
  pinMode(LDR,INPUT);                //Declaring Light sensor as input device
  pinMode(LED,OUTPUT);              //Declaring Bright LED as output device

}

void loop() {
  int a=digitalRead(LDR);            
  if (a==1)
  {
    digitalWrite(LED,LOW);       //If Light sensor senses sunlight, Bright LED will remain OFF
  }
  if (a==0)
  {
    digitalWrite(LED,HIGH);      //If Light sensor does not sense any sunlight, the Bright LED will turn ON
  }

}

Output:

Once the code is uploaded, we can see that the Bright Led on pin 2 turns ON when you place a hand near the Light Sensor on pin 6 then it turns OFF once your hand moves away from it. 

Please enter your email address to receive your cart as a PDF.