Labels

Sunday, 28 April 2013

Added the alarm !

Some of the code for the alarm:

void loop() {
  int sensorValue = analogRead(A0);
if (sensorValue > 600) {
   analogWrite(3, 100);
  delay(1000);
  analogWrite(3, 150);
  delay(1000);
  }
  else {
       digitalWrite(3, LOW);
  }
}

What this is saying is when light is struck upon the LDR (with an intensity of 600+) the alarm will go off but when there is less than 600 the alarm is silent.

The circuit complete with LDR and Alarm:

No comments:

Post a Comment