EAL727Capt
Well-known member
I'm attempting to write a code for a Teensy 4.1 board interfaced with my X-Plane 11 simulator and am running into brick walls.
Right now, I'm working on a function in my home cockpit called ENG FAIL / PRESS TO CANCEL
In a nutshell, if any engine fails, it illuminates two (2) lights on the glare shield, one (1) on each side, Captain and First Officer.
Pressing either of these lighted buttons will acknowledge the failure and extinguish the lights. I had previously written the code for the ENG FAIL portion, using an relay to control the 28VDC lights and it works beautifully but am having trouble in finding the solution for the PRESS TO CANCEL part, which kills the lights.
My latest attempt at this function is as follows:
N.B. I'm only testing Engine 1 (of 3) right now. If I can get Engine 1 to work, I'll add additional lines for Engines 2 and 3.
/*
TESTING ENG FAIL/PRESS TO CANCEL
When any engine fails, the affected engine's data ref goes to a state of '6'
When the PRESS TO CANCEL button is pressed, this resets the engine's data ref to a state of '0'
*/
int EngFailReset = 1;
FlightSimFloat Eng1Fail;
void setup() {
Serial.begin(9600);
pinMode(EngFailReset, INPUT_PULLUP);
Eng1Fail = XPlaneRef("sim/operation/failures/rel_engfai0");
}
void loop() {
FlightSim.update();
if (digitalRead(1) == HIGH); {
Eng1Fail = 0;
}
}
The above compiles without issue but when put into practice and tested in the sim, it doesn't do anything when either PRESS TO CANCEL button is pressed. I did check and do have continuity on both side's switch buttons, via a multimeter, so I know that the wiring is correct and working.
I've tried CONST INT, OUTPUT, digitalWRITE, etc., all to no avail and it is making me nuts!
Previously, I've had no issues with creating a code for a push button and have several switches and buttons that I've successfully interfaced thus far...but this one's got me wandering aimlessly in circles in the dark.
Any help and constructive suggestions are most certainly welcomed.
Thank you all very kindly.
Jay
Right now, I'm working on a function in my home cockpit called ENG FAIL / PRESS TO CANCEL
In a nutshell, if any engine fails, it illuminates two (2) lights on the glare shield, one (1) on each side, Captain and First Officer.
Pressing either of these lighted buttons will acknowledge the failure and extinguish the lights. I had previously written the code for the ENG FAIL portion, using an relay to control the 28VDC lights and it works beautifully but am having trouble in finding the solution for the PRESS TO CANCEL part, which kills the lights.
My latest attempt at this function is as follows:
N.B. I'm only testing Engine 1 (of 3) right now. If I can get Engine 1 to work, I'll add additional lines for Engines 2 and 3.
/*
TESTING ENG FAIL/PRESS TO CANCEL
When any engine fails, the affected engine's data ref goes to a state of '6'
When the PRESS TO CANCEL button is pressed, this resets the engine's data ref to a state of '0'
*/
int EngFailReset = 1;
FlightSimFloat Eng1Fail;
void setup() {
Serial.begin(9600);
pinMode(EngFailReset, INPUT_PULLUP);
Eng1Fail = XPlaneRef("sim/operation/failures/rel_engfai0");
}
void loop() {
FlightSim.update();
if (digitalRead(1) == HIGH); {
Eng1Fail = 0;
}
}
The above compiles without issue but when put into practice and tested in the sim, it doesn't do anything when either PRESS TO CANCEL button is pressed. I did check and do have continuity on both side's switch buttons, via a multimeter, so I know that the wiring is correct and working.
I've tried CONST INT, OUTPUT, digitalWRITE, etc., all to no avail and it is making me nuts!
Previously, I've had no issues with creating a code for a push button and have several switches and buttons that I've successfully interfaced thus far...but this one's got me wandering aimlessly in circles in the dark.
Any help and constructive suggestions are most certainly welcomed.
Thank you all very kindly.
Jay