Issues with xplane programming - code attached

Hi all,
I am a newbie to arduino and have been trying to write code for a plane sim controller.

I have 3 encoders, several switches and buttons which I need to perform functions within the simulator. I have been reading and learning what I can but I have run in to a problem.

When I operate the master/alternator/avionis switches they seem to lock out the operation of any of the other switches? If I operate the other switches there is no problem?

I am guessing that there are many mistakes in my code and I would be grateful to anyone who might be able to help me correct it.

Thank you for your time in reading,

Andy

xplane_ctrl.ino (17.4 KB)

Hi Andy and welcome to the Forum. It’s often useful when writing code to adopt a style that includes formatting. This gives you, among other things, a quick visual which sometimes reveals errors such as mis-matched braces. I’ve taken the liberty of re-formatting your code. Have a look at it and see if that’s what you truly intended.

xplane_ctrl.c (20.4 KB)

void loop() {
  FlightSim.update();
  

 
  // divide by 4 to find how many clicks the encoder's been turned
  // (+ve clockwise, -ve anticlockwise, normally)
  short vor1Clicks = (vor1Encoder.read() - vor1EncoderPrevious) / 4;
 
  // when encoder 'clicks' into a new detent:
  if (vor1Clicks != 0) {

I hope your horse likes pushing that cart. I can’t see ANY reason to update flight sim with old data and then get new data. Get the new data and THEN update flight sim.

If I operate the other switches there is no problem?

How are WE supposed to answer that? You are the one with the hardware and the eyes on the action.