I am working on a midi guitar type thing that uses an arduino (obviously), midi shield, lcd, capsense for frets, and lasers for strings. I am having problems programming the photoresistor detection so that it behaves more like strings. Currently I have the midi msg in a plain IF statement and it works ok for moderately paced strumming.
if(analogRead(0) < SetThreshold){
midi msg;
}
But this of course will cause notes to repeat if the strumming hand lingers to long. I then threw a WHILE statement in there (can't remember how it went), which took care of the repeating notes but if a laser was still blocked while the strum was on its way to the next laser, that laser wouldn't play until the first laser was unblocked....in otherwords it was still stuck in the first lasers loop. I also tried to implement some change in state detection only to find that I am a horrible programmer, if you haven't been able to tell by now. I have scoured the interwebs looking at other projects and sketches like mine but nothing dumbed down to my level.
My ideal solution would be for the note to sound once after the cds value returns back above the set threshold...much like a guitar string being plucked, the string is briskly held at tension but doesn't sound until released.....so something like...
detects sensor is below threshold //laser blocked
detects sensor is above threshold // laser is hitting cds again
plays note once // until next strum/pluck and doesn't interfere with other laser detection
Though I would just be happy with it playing one note on first detection of a blocked laser without interfering with the other lasers ability to sound notes.
Any insight or guidance would be greatly appreciated!!! I'm sure it is going to be an easy solution that i will be kicking myself over. Also any notes on playing notes (detecting changes) simultaneously (nearly simultaneous) would be great! Thanks!!!