I spent hours on this today trying to fathom out the delay - whatever I tried, in whatever order, the delay was the same. I read your latest post and cross referenced the timeout; you're spot-on - pulseIn blocks code execution for a default which is 1 second, after which it returns zero if no input is detected. As soon as I set my own timeout everything worked just fine. The gate signal is perfect. Really snappy with sensing the guitar and no glitching as the note fades or when damped. Can't wait to build the revised input circuit.
The change needed was:
Htime = pulseIn(guitar_in, HIGH, 5000UL); // read high time
Ltime = pulseIn(guitar_in, LOW, 5000UL) ; // read low time
I just set an arbitrary 5000 microseconds as a test but it seems to work really well at that.
EDIT: I noticed the LED wasn't as bright as it was previously and the timeout needed to increase to 15000 to prevent the LED and gate pins from strobing on low frequencies.
The change needed was:
Htime = pulseIn(guitar_in, HIGH, 5000UL); // read high time
Ltime = pulseIn(guitar_in, LOW, 5000UL) ; // read low time
I just set an arbitrary 5000 microseconds as a test but it seems to work really well at that.
EDIT: I noticed the LED wasn't as bright as it was previously and the timeout needed to increase to 15000 to prevent the LED and gate pins from strobing on low frequencies.
Comment