int high_threshhold = 20; int low_threshhold = 5; int debouncing = 500; int nrOfSensors = 13; boolean trigger[13]; unsigned long timeStamp[13]; void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { for (int x = 0; x < nrOfSensors; x++) { //we repeat the block below, x increases every time int sensorValue = analogRead(A0 + x); if (sensorValue >= high_threshhold) trigger[x] = false; if ((sensorValue < low_threshhold) && (trigger[x] == false)) { if ((millis() - timeStamp[x]) > debouncing) { Serial.write (x); trigger[x] = true; timeStamp[x] = millis(); } } } }