Hi Paul, thanks very much for your input. I looked at both Bounce and Bounce2 but decided it was better for me to look for trailing edge detection (does not appear in my test code) using the following sort of code for each button (of which there are many), then the Delay() does become the de-bounce time.
LHButton = digitalRead(18); //Left Hand Control Knob Push.
if (LHButton == HIGH && lastLHButton == LOW) {
ModeLH = ModeLH + 1;
if (ModeLH > 3) {
ModeLH = 1;
}
}
lastLHButton = LHButton;
This seems to work well for all the different buttons I have. The test code itself works OK in as much as I wanted the LHButton to remain pressed for 200 program cycles (approx. 2 seconds) before the headingbug is made equal to the Heading.
My real question was controlling the flow of data to and from X-Plane. I think I may have answered my own question and am now thinking of making "FlightSim.Update()" conditional rather than run every program cycle. In my set up I know when I want to talk to X-Plane and when I want to get data from it, so I can decide when to communicate with X-Plane. I believe though that this would control all communications between Teensy and X-Plane?? It would be nice if there was a way of requesting data from X-plane (Output from X-Plane) and separately sending data to X-Plane (Input to X-Plane). But I guess these two aspects are not separate-able??
Wishing you a Happy New Year and thanks for your support.
BR Pete D.