Hello, I have a piece of code adapted from a single button to control two positions on a single servo.
My intention is to control three servos with incoming midi notes. Each servo is positioned to pluck one guitar string. Each servo responds to an assigned midi note so that each time the same midi note is played that same servo will alternate between two chosen positions. I have three servos in total. My problem is that the servos don't respond to the first note played but they will with each consecutive note assigned to them.
The next problem occurs when changing between servos. When I alternate between midi notes consecutively, none of the servos move. They appear to need the same midi note at least twice before the next servo will operate. I'm sure there's a problem in the loop function but then maybe this code doesn't suit what I'm trying to achieve? Thank you for your help
If your MIDI output is connected to the hardware serial pins, you need to get it connected to some other pins, so that you can use Serial to debug your program. You need to know when Note() gets called. You need to know what value is in note when Note() gets called.
You have three servos and one toggle variable. Is that the correct ratio? IMHO, it is not.
An array probably is the best way UKHeliBob. This code though spawned from another piece that actually did start working for me so I ran with it. The reason there is no sevoPos3 is because I'm only using two servo positions to alternate between, upwards and downwards picking on a guitar string.