/ TEST KOD
/*
 Sound Sensor Playing
 Reads the analog output of Sound Sensor through A0, 
 prints the result to the serial monitor 
 Read the digital output of Sound Sensor throug A1, 
 prints the result to the serial monitor
 
 Connect the pins in the following way:
 GND----GND
 VCC----5V
 A------A0
 D------A1
 */
void setup() {
  Serial.begin(9600);
  pinMode(4,OUTPUT); //RED
  pinMode(2,OUTPUT); //GREEN
  digitalWrite(2,HIGH); //GREEN
  Serial.println("ALARM IS ACTIVE AND ARMED...");
}
void loop() {
  int sensorValue = analogRead(A0); //Read the analog value of the sound sensor
  int digitalVlaue = digitalRead(15);//Read the digital value of the sound sensor
  // Serial.print("Analog Vlaue=");
  // Serial.println(sensorValue);//Print the analog value to serial monitor
  if(digitalVlaue){
  Serial.println("ALARM IS TRIGGED!!");
  digitalWrite(2,LOW); //GREEN
  digitalWrite(4,HIGH); //RED
  delay(3000);              // wait for a second
  digitalWrite(4,LOW); //RED
  digitalWrite(2,HIGH); //GREEN
  Serial.println("ALARM IS AUTO RESET AND ARMED...");
 }
}
 |