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

4 Stage Timer With DS3231RTC Module.

Interfacing KY038 sound sensor with Raspberry pi Pico

Interfacing MQ2 Gas & Smoke Sensor With Raspberry Pi Pico