       //reset:
       signalMax[pin] = 0;
       signalMin[pin] = 1024;
-      
       startMillis = millis();
       
-      checkSoundStates();
-    }
-    
-    sendSoundLevels(0, soundValues[0]);
- }
-}
-
-void checkSoundStates(){
-  
+      // check sound state (SOUND or SILCENCE):
+      checkSoundState(pin, soundValues[pin]);
+      
+      // send sound level (if required):
+      sendSoundLevel(pin, soundValues[pin]);
+    }
+  }
+  
+  readIncommingNodeData();
+}
+
+void checkSoundState(int pin, int level){
+  if(pin != 0) return; //only check pin 0 for now
+    
   if( currentState == 0 ) {
-    //no sound
-    if(soundValues[0] > silenceThreshold){ // if louder than silenceThreshold
-      silenceCapacitor--;
+    // IF SILENCE
+    
+    if(level > soundThreshold){ // if louder than soundThreshold
+      soundSampleCounter++;
     }else{
-      silenceCapacitor = silenceSamples; // reset capacitor
-    }
-    
-    if(silenceCapacitor <= 0){
-      silenceCapacitor = 0; //cap
-      currentState = 1; // flip to "there is sound"
-      soundCapacitor = soundSamples;
-      
-      updateState(0, 1);
+      soundSampleCounter = 0; // reset
+    }
+    
+    if(soundSampleCounter >= nrOfConsecutiveSoundSamplesBeforeFlippingToSilence){
+      currentState = 1; // flip to "SOUND"
+      soundSampleCounter = 0; // reset soundSampleCounter for the next time there is SILENCE
+      
+      sendSoundState(pin, currentState); // send sound state to Node.js
     }
     
   }else{
-    // sound
-    
-    if(soundValues[0] < soundThreshold){ // if quieter than soundThreshold
-      soundCapacitor--;
+    // IF SOUND
+    
+    if(level < silenceThreshold){ // if quieter than silenceThreshold
+      silenceSampleCounter++;
     }else{
-      soundCapacitor = soundSamples; // reset capacitor
-    }
-    
-    if(soundCapacitor <= 0){
-      soundCapacitor = 0; //cap
-      currentState = 0; // flip to "there is silence"
-      silenceCapacitor = silenceSamples;
-      
-      updateState(0, 0);
-    }
-    
-  }
-  
-  
-
-}
-
-void updateState(int pin, int state)
-{
-  // only send state if different from previous:
-  if(currentSoundState[pin] != state)
-  {
-    currentSoundState[pin] = state;
-
-    digitalWrite(ledPin, state); // turn LED on/off
-
-    sendSoundState(pin, state);
-  }
-}
-
+      silenceSampleCounter = 0; // reset
+    }
+    
+    if(silenceSampleCounter >= nrOfConsecutiveSilenceSamplesBeforeFlippingToSound){
+      currentState = 0; // flip to "SILENCE"
+      silenceSampleCounter = 0; // reset silenceSampleCounter for the next time there is SOUND
+
+      sendSoundState(pin, currentState);
+    }
+  
+  }
+}
 
 void sendSoundState(int pin, int state) {
+  digitalWrite(ledPin, state); // debug to LED
+  
   if(debug) Serial.print("> pin: ");
   if(debug) Serial.print(pin);
   if(debug) Serial.print(" | state: ");

}


void sendSoundLevels(int pin, int level){
//  return;
  
  uint16_t number = level;
  uint16_t mask   = B11111111;
  uint8_t first_half   = number >> 8;
  uint8_t sencond_half = number & mask;
  
  // always start with 3 bytes of 255 so that Node.js knows were this 'packet' starts:
  NodeSerial.write(255);
  NodeSerial.write(255);
  NodeSerial.write(255);
  NodeSerial.write(03); // 03 = soundlevel
  NodeSerial.write(pin);  // channel
  NodeSerial.write(first_half);   // value, first byte (Big Endian)
  NodeSerial.write(sencond_half); // value, last byte  (Big Endian)
}





  NodeSerial.write(state); // volumeon
  NodeSerial.write(0); // empty byte, because we always expect 4 bytes ;-)
}



void sendSoundLevel(int pin, int level){
  if(pin != 0) return; //debug
  
  
  
  uint16_t number = level;
  uint16_t mask   = B11111111;
  uint8_t first_half   = number >> 8;
  uint8_t sencond_half = number & mask;
  
  // always start with 3 bytes of 255 so that Node.js knows were this 'packet' starts:
  NodeSerial.write(255);
  NodeSerial.write(255);
  NodeSerial.write(255);
  NodeSerial.write(03); // 03 = soundlevel
  NodeSerial.write(pin);  // channel
  NodeSerial.write(first_half);   // value, first byte (Big Endian)
  NodeSerial.write(sencond_half); // value, last byte  (Big Endian)
}






void readIncommingNodeData() {
  // READ RESPONSE
