LDR using arduino board

SOURCE CODE

const int ldrpin = A0;
const int ledpin = 7;
void setup() {
pinMode(ledpin, OUTPUT);  // put your setup code here, to run once:
}
void loop() 
{
  int sensorValue = analogRead(ldrpin);
   if (sensorValue<150)
    digitalWrite(ledpin, HIGH);
  else 
    digitalWrite(ledpin, LOW);
    
}
Circuit Diagram





Comments

Popular Posts