Automatic Dark sensing Light with Arduino and LDR

 


//https://github.com/anokhramesh/ON-LED-with-LDR/blob/main/Automatic%20Dark%20sensing%20Light.png


#define LDR A0// connect an LDR to A0 pin of Arduino as per the circuit diagram.

#define LED 8 // connect an LED to pin # 8 of Arduino

float x;

void setup() {

  Serial.begin(9600);

  pinMode(LED,OUTPUT);

}


void loop() 

{

  x=analogRead(A0);

  x= x/10;

  Serial.print("Value");

  Serial.println(x);

  if (x<60)

  {digitalWrite(LED,HIGH);}

  else

  {digitalWrite(LED,LOW);}

  delay(1000);

}

Comments

Popular posts from this blog

Proteus simulation 4x4 Matrix Keypad with Arduino and LCD screen

Digital Clock with Arduino and RTC Module and P10 LEDmatrix

Interfacing KY038 sound sensor with Raspberry pi Pico