Jump to content

DCS BIOS CDU Buttons on a single pin


DZ82

Recommended Posts

Hi all,

 

I am trying to combine multiple CDU buttons for the A-10C to function off a single pin.

 

I have connected 220ohm resistors between each button as voltage dividers, so my plan is to use the analog values that register with each button press to register each button on the CDU.

 

The single button example below compiles in Arduino IDE (this is button2 in a series of 3 buttons connected to pin A0), but doesn't work in DCS. I know this is probably not correct, but I don't know how to fix it. I will try to fiddle around in the meantime, but would appreciate any input!

 

Thanks!

 

void loop() {

DcsBios::loop();

 

buttonValue = analogRead(A0);

 

if(buttonValue >= 678 && buttonValue <= 685){

DcsBios::Switch2Pos cduA("CDU_A", A0);

}

 

}

Link to comment
Share on other sites

Hi DZ82. You will have to use the sendDcsBiosMessage function to trigger the commands when you need them. The only problem is you will need to send both press and release commands separately. You could use a small delay or some logic to release the button in DCS when buttonValue is 0.

 

Replace the DCSBIOS line:

DcsBios::Switch2Pos cduA("CDU_A", A0);

 

With this version:

sendDcsBiosMessage("CDU_A", "1");
delay (50);
sendDcsBiosMessage("CDU_A", "0");

 

This is exactly how I plan to wire MFCDs so I'm interested to see how you get on.

Link to comment
Share on other sites

#define DCSBIOS_IRQ_SERIAL

 

#include "DcsBios.h"

 

int buttonValue = 0;

 

DcsBios::Switch2Pos cduA("CDU_A", A0); //Not sure if this is necessary, doesn't seem to make a difference

 

void loop() {

DcsBios::loop();

 

buttonValue = analogRead(A0);

 

if(buttonValue >= 675 && buttonValue <= 685){

sendDcsBiosMessage("CDU_A", "1");

}

else

{

sendDcsBiosMessage("CDU_A", "0"); //also tried this without else statement and with 50ms delay

}

 

 

}

 

Hi Boltz,

 

Thanks for your response. I still can't get it to work, but I will also troubleshoot this a bit, re-check all the wiring etc.

 

When you do get around to trying it, please let me know how it goes. Yes, there are other ways, but for now I am determined to figure out (with lots of help) why this isn't working right now.

Link to comment
Share on other sites

I have connected 220ohm resistors between each button as voltage dividers, so my plan is to use the analog values that register with each button press to register each button on the CDU.

 

Try setting up the arduino to test you're getting the right numbers out of your resistor chain. I usually make part of my program output the numbers to an I2C character display.

 

If it doesn't work with the DCS-BIOS code in there as well as the display, I start from a blank program and get the input stuff working first, then add the DCS-BIOS code.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...