     unsigned int uS = sonar.ping();             // Send ping, get ping time in microseconds (uS).
     unsigned int distance = uS / US_ROUNDTRIP_CM;
     Serial.println(distance);
-    if(distance < 70) {
+    if(distance < DOOR_WIDTH && distance > 0) {
       triggered = true;
     }
   } 

void loop(){
  Serial.print("Alarm delay: "); Serial.println(alarmDuration);
  if(triggered == true && alarmDuration < MAX_ALARM_TIME) {
    alarmDuration += 250;
    alarm();
  } else if(triggered == true) {
    alarmDuration = 0;


void alarm(){
  color(225,0,178);    //red
  delay(100);
  color(0,199,225);  //yelow
  delay(100);
  color(4,225,0);
  delay(100);
  color(109,57,1);
  delay(100);
  color(8,0,225);
  delay(100);
  color(242,225,0);
  delay(100);
  for (int x=0; x<180; x++) {
    // convert degrees to radians then obtain sin value
    sinVal = (sin(x*(3.1412/180)));
