Greetings,
I have a sketch I am working on that uses the Servo.h library to manage a speed controller. I have everything working except for a key safety feature. In a certain situation I need to completely stop the engine using the speed control. Currently I am just using the following code to stop the engine:
if (run == true) {
jets.writeMicroseconds(pulseLength + pulseBase);
delayMicroseconds(pulseInterval - pulseLength);
} else {
jets.writeMicroseconds(1000);
delayMicroseconds(19000);
}
The else block sends the correct command to stop the engine. But I get a time lag of about .5 seconds. Does anyone know of a way to improve this? I know the Servo library uses Timer1 under the covers so i was thinking maybe an interrupt. But I don't see a way to trigger an interrupt programmatically from inside my sketch. Another thought i had was detaching the pins using Servo.detach().
any thoughts would be greatly appreciated.
thx