In your original program, try changing the 0102 if statement to this ...
//SENSOR 0102---------------------------------------------------
if ((sensorValue01 > threshold || sensorValue02 > threshold) && Key1LastState0102 == false) { // at least 1 sensor off, so turn note off
MIDI_TX(128,sensornote0102,127);
Key1LastState0102 = true;
}
else if (sensorValue01 < threshold && sensorValue02 < threshold && Key1LastState0102 == true) { // sensors on, so turn note on
MIDI_TX(144,sensornote0102,127);
Key1LastState0102 = false;
}
I made a false assumption about what the Key1LastStateXXX booleans meant - I should have checked 
If this works, I have some suggestions for improving the readability of the code, which will help as you develop the project.
harp_test_04 works correctly
Cool!
Sorry it took a while.
I think it would help if you change the names of the boolean variables so they more clearly explain the state of the "key".
So instead of "Key1LastState02", make it "key02WasOn" or something like that.
You could also hide the comparison with the threshold, like this.
boolean key02On = false;
...
key02On = (analogRead(A1) < threshold);
Then use "key02On" in your if statements.
As you expand this to more sensors, you probably will want to change these variables to be arrays, so you can do the same logic for each sensor reading in a for loop, rather than writing out effectively the same code many times.
I've got some questions about the 8 x 8. I'll post them in a minute.
Thank you for the earlier reply about the 8 x 8 matrix. I think I understand.
Take a look at the attached diagram. I have labelled the 16 sensors, and also shown three places where a hand is crossing a beam, marked a, b and c.
What I understand is:
- If you break the beam at a, you want the single note for Sensor B to play.
- If you take out your hand from a and put it in at b, you want the previous note to stop and the single note for Sensor 6 to play.
- If you take your hand out from b and put it in at c, you want the previous note to stop and then the following to be played: the single note for Sensor G, the single note for Sensor 8 and the special note that relates to position G8 (so, one of the 64 extra notes).
If that is correct, then what do you want to happen if my hand is already at c, and the three notes are playing, and then I put my other hand into the grid, for example at a?
Regards
Ray
grid.pdf (226 KB)
everything you state is correct
If that is correct, then what do you want to happen if my hand is already at c, and the three notes are playing, and then I put my other hand into the grid, for example at a?
then we will have 4 sounds playing
(note that the red figure are the lasers, and the black figure are the photoresistors. you understood them the other way around)
Ray!
I am very happy we sorted this out!!!!
and I have just realized that we have been both trying to perform the changes in the incorrect if statement!!! very big mistake from my part. it would have been much easier if I would have realized this before... sorry for that.
regarding your advices on code writing, I will check them in detail and consider the seriously!
THANK YOU SO MUCH!
OK, and if my second hand goes in at a node as well, I guess you want six sounds playing?
It sounds like you need arrays to make the program practical: to hold the status of whether each note is currently being played or not; to hold the code you need to send to MIDI for each note; and maybe in other places too.
You could set up 2-dimensional arrays (8 x 8 elements) to hold the data that relates to the 64 nodes. For example, the booleans that say whether each node note is being played or not.
But you also need data that just relates to the rows or the columns. For example, the booleans that say whether each single note is being played, which is independent of the node notes. You could set this up as separate 1-dimensional arrays (a 1 x 16 or two 1 x 8s), or you could use the first row and column of the 2-D array if you make the array 9 x 9. So row 0 and column 0 have this special purpose, then rows 1 - 8 and columns 1 - 8 relate to the 16 sensors.
On the hardware side, there are only 6 analogRead capable pins on a Uno, I believe. It should be possible to configure your sensors so that the voltage going to the Arduino can be read on a digital pin as high or low, which is all you want in this application anyway.
Regards
Ray
THANK YOU SO MUCH!
No problem. Hope the project goes well.
I am using an arduino mega, recibing 16 sensors and feeding the 16 lasers as well. this is already tested and working.
regarding arrays and stuff, I have no idea what they are. but I will certanly investigate in that direction. now I need a pause!

Understood 
I would suggest improving the readability of the code first in your current program. Think about places where using functions (like your MIDI_TX) helps by hiding some of the detail.
Then, read up about arrays in the tutorials on this website, and make sure you understand the examples. For practice, try to change your current program to use arrays, even though you only have two sensors and it may seem over the top. Better to start with a small example.
All the best
Ray