   for (int i = 0; i <= LASTPORT; i++) {
     if(analogRead(i) > THRESHOLD) {
 #ifndef WIND
-      if (lastNote != i) {
+      if (!(lastNote & (inttomask(i)))) {
 #endif
         // Beam has been cut
         // i+1 is because i is 0 indexed, but the ID starts with 1
-        if (i < 4) {
-          musicOn(i + 1);
+        musicOn(i + 1);
 #ifndef WIND
-          lastNote = i;
-#endif
-        } else if (i == 4) {
-#ifndef WIND
-          if (lastNote != 314) {
-#endif
-            if (noteSet == 1) {
-              noteSet = 2;
-            } else {
-              noteSet = 1;
-            }
-#ifndef WIND
-            lastNote = 314;
-          }
-#endif
-        }
-#ifndef WIND
+        lastNote |= (inttomask(i));
       }
 #endif
     } else {
 #ifndef WIND
       if (lastNote == i) {
-        lastNote = -1;
+        lastNote &= ~(inttomask(i));
       }
 #endif
       // Hand is gone. Stop the sound

  // Set instrument to trumpet
  // 0xC0 is the change instrument command
  // 0x39 is the instrument ID in hex
  // Serial.write(CHANGEINSTRUMENT);
  // Serial.write(INSTRUMENT);
}

// Function for playing note based on ID

#define NOTEON 0x90
#define NOTEOFF 0x80
#define CHANGEINSTRUMENT 0xC0
#define INSTRUMENT 0x39

// Values for different notes
