int wire = A3;    
int value, alarm;
int button = 8;     
int led = 2;

void setup() {
  Serial.begin(9600);
  Serial.write(27); 
  Serial.print("[3;10H");
  Serial.print("---===[ Silent Alarm ]===--- ");
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);       
}

void loop() {
  // measure resistance
  value = analogRead(wire); 
  
  // check against ranges
  alarm=0;
  if (value>920 and value<=1003){
    alarm=1;
  }
  if (value>300 and value<=920){
    alarm=2;
  }
  if (value<=300){
    alarm=3;
  }
  
  // report findings
  Serial.write(27); 
  Serial.print("[7;10H");
  if (alarm==0){
      Serial.print("All is safe                            ");
      digitalWrite(led, LOW);    
  }
  else {
    Serial.print("Perimeter breach in section ");
    Serial.print (alarm);
    digitalWrite(led, HIGH);    
    while (digitalRead(button) == LOW);
  }

  delay(100);
  
}

