LDR Sensor Code



                CODE

const int ldr = 7;

const int led = 13;

void setup() {

  pinMode(ldr,INPUT);//define pin as input sensor

  pinMode(led,OUTPUT);//define pin as output sensor

}

void loop() {

int y =digitalRead(ldr);//read the sensor

if (y==1){

  digitalWrite(led,LOW);//turn on led

}else{digitalWrite(led,HIGH);//turn off led

}

delay(500)

}

Post a Comment

Previous Post Next Post

Contact Form