Saturday, December 19, 2015

arduino LDR controller

                    Arduino LDR controller 


the circuit diagram here


FIRST YOU MUST GET THE VALUE FROM THE LDR READING FOR WHAT BRIGHTNESS
YOU WANT TO  CONTROL WITH THE SERIAL MONITOR 

the ldr value reading cord is here

int sensePin =0;

void setup()
{
 analogReference(DEFAULT);
 Serial.begin(9600);

}
void loop() {
    Serial.println(analogRead(sensePin));
   delay(500);

}

after getting the value of ldr with the serial monitor


then the led controlling cord is follow . in this cord we set it when the led valu is <150
LED ON else LED OFF

the cord is follow 

int sensePin =0;
int ledPin = 13;
void setup()
{
  analogReference(DEFAULT);

 pinMode(ledPin, OUTPUT);

}
void loop()
{
  int val = analogRead(sensePin);

  if(val <150) digitalWrite(ledPin, HIGH);

  else  digitalWrite(ledPin, LOW);

}

after this we programming for controlling the led brightness when led values changing 




No comments:

Post a Comment