Jump to content

MarkBLN

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by MarkBLN

  1. Cheers. Ya the problem was the code I was using wasn't specifically referring to LEDs. The issue was on both digital and analog pins. The 2 different cases I had was firstly, I wanted the backlit selective jettison button to be off when the select jettison dial was set to safe, then illuminate when set to any other setting apart from safe. That's the one you helped me with the code for. The other case was to mimic a magnetic switch for the engine crank. I have 2 LEDs, one each side of the crank switch. My switch is momentary, not latched. So how it works is when I press it to the right the in game switch moves to the right and latches, then my right hand light illuminates to simulate this. Then when the engine has started successfully and the ingame switch is released to centre, the right hand light goes off. Then this is repeated with the left side. So ya, both of those sets of LEDs were the ones that were dim until I put in the code to specify that they were output pins.
  2. Figured it out. in the section at the end that says.. void setup() { DcsBios::setup(); } I added... pinMode(A13, OUTPUT); pinMode(A14, OUTPUT); pinMode(15, OUTPUT); Now the LEDs are full brightness. Here's the finished result. Made from MDF, HDF, carbon fiber foil, pin striping tape and a hand label punch. Only have a handsaw and battery screwdriver that I borrowed from a mate So I'm happy with the result considering the limited resources.
  3. Thanks mate, this worked once I added == instead of = Happy to have it all working now though. One funny issue is that when the button LED is triggered by the above command the light is very dim, whereas if I use some code to let's say just light the button when the landing gear is down then it is fully bright. I can't figure out what is it about this specific code that limits the light output of the LED?
  4. I tried the code with that and didn't work. I tired some other code to just get the light to light up and it's lighting fine, so seems the code isn't right for what I'm trying to do sadly. I'll mess around more tomorrow and see if I have any luck. Thanks for the help.
  5. Where do I reference the pin for the LED I want to illuminate in this code?
  6. None of my pots work, so I guess I messed up the wiring. How should they be wired? Just 2 wires, ground and to a pin, or 3 wires ground, 5v and to a pin?
  7. Thanks. I'll have a look tomorrow and see
  8. That seemed to help with getting almost no errors now. The only 2 lines I am still having issues with are the last 2. What I wanted to do was have an LED illuminate when the engine start switch if engaged and held in position in the sim, and then the LED goes out when the engine has started and the switch in the cockpit returns automatically to the middle position. This was a poor man's solution to magnetic switches. So I am using a 3 way momentary switch instead of a latched switch. So I press the toggle in one direction, the light illuminates to show the engine is starting, then the light goes out when the engine is running and the switch in game returns to the neitral position. I am struggling to find out what code to put in to get this to work though. Then the final thing I wanted to do was as follows.. (dunno if it is possible though?).. I have a backlit momentary push button for the selective jettison button. What I wanted to do was have the led in that button to be lit all the time, EXCEPT when the jett selector switch is set to SAFE. Then the button light goes out. Is that possible?
  9. Ok that makes sense. Cheers.
  10. Ah ok. I thought the name had to reference exactly so as it knows which switch I'm referring to.
  11. But the first was an input and the second was an output. Does that not work?
  12. So I finally got my panel built and wired up and just doing the code now with DCS bios and the mega. I went to upload but I am getting some errors. If I post the code here can someone have a look and see what the errors are? I am totally clueless so would appreciate any help with this. /* Tell DCS-BIOS to use a serial connection and use interrupt-driven communication. The main program will be interrupted to prioritize processing incoming data. This should work on any Arduino that has an ATMega328 controller (Uno, Pro Mini, many others). */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" /* paste code snippets from the reference documentation here */ /* PIN 2 */ DcsBios::ActionButton selJettBtn("SEL_JETT_BTN", "1", 2); /* PIN 3, 4, 5, 6, 7 */ const byte selJettKnobPins[5] = {3, 4, 5, 6, 7}; DcsBios::SwitchMultiPos selJettKnob("SEL_JETT_KNOB", selJettKnobPins, 5); /* PIN 8 */ DcsBios::Switch2Pos ldgTaxiSw("LDG_TAXI_SW", 8); /* PIN 9, 10 */ DcsBios::Switch3Pos flapSw("FLAP_SW", 9, 10); /* PIN 11 */ DcsBios::Switch2Pos gearLever("GEAR_LEVER", 11); /* PIN 12 */ DcsBios::Switch2Pos launchBarSw("LAUNCH_BAR_SW", 12); /* PIN 13 */ DcsBios::Switch2Pos antiSkidSw("ANTI_SKID_SW", 13); /* PIN 14 */ DcsBios::Switch2Pos hookBypassSw("HOOK_BYPASS_SW", 14); /* PIN 15 */ DcsBios::LED selJettBtn(0x7480, 0x0100, 15); /* PIN 16 */ DcsBios::LED flpLgRightGearLt(0x7430, 0x2000, 16); /* PIN 17 */ DcsBios::Switch2Pos pitotHeatSw("PITOT_HEAT_SW", 17); /* PIN 18, 19 */ DcsBios::Switch3Pos engAntiiceSw("ENG_ANTIICE_SW", 18, 19); /* PIN 20, 21 */ DcsBios::Switch3Pos wshieldAntiIceSw("WSHIELD_ANTI_ICE_SW", 20, 21); /* PIN 22 */ DcsBios::Switch2Pos hookLever("HOOK_LEVER", 22); /* PIN 23, 24 */ DcsBios::Switch3Pos cockkpitLightModeSw("COCKKPIT_LIGHT_MODE_SW", 23, 24); /* PIN 25, 26 */ DcsBios::Switch3Pos probeSw("PROBE_SW", 25, 26); /* PIN 27, 28 */ DcsBios::Switch3Pos extWngTankSw("EXT_WNG_TANK_SW", 27, 28); /* PIN 29, 30 */ DcsBios::Switch3Pos extCntTankSw("EXT_CNT_TANK_SW", 29, 30); /* PIN 31 */ DcsBios::ActionButton fuelDumpSw("FUEL_DUMP_SW", "1", 31); /* PIN 32, 33 */ DcsBios::Switch3Pos flirSw("FLIR_SW", 32, 33); /* PIN 34 */ DcsBios::ActionButton ltdRSw("LTD_R_SW", "1", 34); /* PIN 35 */ DcsBios::Switch2Pos lstNflrSw("LST_NFLR_SW", 35); /* PIN 36, 37 */ DcsBios::Switch3Pos strobeSw("STROBE_SW", 36, 37); /* PIN 38, 39, 40 */ const byte radarSwPins[4] = {38, 39, 40}; DcsBios::SwitchMultiPos radarSw("RADAR_SW", radarSwPins, 3); /* PIN 41, 42, 43, 44 */ const byte insSwPins[8] = {41, 42, 43, 44}; DcsBios::SwitchMultiPos insSw("INS_SW", insSwPins, 4); /* PIN 45 */ DcsBios::Switch2Pos gainSwitch("GAIN_SWITCH", 45); /* PIN 46 */ DcsBios::ActionButton fcsResetBtn("FCS_RESET_BTN", "1", 46); /* PIN 47, 48 */ DcsBios::Switch3Pos batterySw("BATTERY_SW", 47, 48); /* PIN 49 */ DcsBios::ActionButton apuControlSw("APU_CONTROL_SW", "1", 49); /* PIN 50, 51 */ DcsBios::Switch3Pos engineCrankSw("ENGINE_CRANK_SW", 51, 50); /* PIN 52 */ DcsBios::Switch2Pos obogsSw("OBOGS_SW", 52); /* PIN A0 */ DcsBios::Potentiometer hmdOffBrt("HMD_OFF_BRT", A0); /* PIN A1 */ DcsBios::Potentiometer floodDimmer("FLOOD_DIMMER", A1); /* PIN A2 */ DcsBios::Potentiometer instPnlDimmer("INST_PNL_DIMMER", A2); /* PIN A3 */ DcsBios::Potentiometer consolesDimmer("CONSOLES_DIMMER", A3); /* PIN A4 */ DcsBios::Potentiometer formationDimmer("FORMATION_DIMMER", A4); /* PIN A5 */ DcsBios::Potentiometer positionDimmer("POSITION_DIMMER", A5); /* PIN A6 */ DcsBios::LED fuelDumpSw(0x74b4, 0x0100, A6); /* PIN A7 */ DcsBios::LED batterySw(0x74c4, 0x1800, A7); /* PIN A8 */ DcsBios::LED apuControlSw(0x74c2, 0x0100, A8); /* PIN A9 */ DcsBios::ActionButton fuelDumpSw("FUEL_DUMP_SW", "0", A9); /* PIN A10 */ DcsBios::ActionButton ltdRSw("LTD_R_SW", "0", A10); /* PIN A11 */ DcsBios::LED ltdRSw(0x74c8, 0x4000, A11); /* PIN A12 */ DcsBios::ActionButton apuControlSw("APU_CONTROL_SW", "0", A12); /* PIN A13 */ void onEngineCrankSwChange(unsigned int newValue) {DcsBios::LED engineCrankSwBuffer(0x74c2, 0x0600, A13);}DcsBios::IntegerBuffer engineCrankSwBuffer(0x74c2, 0x0600, 9, onEngineCrankSwChange); /* PIN A14 */ void onEngineCrankSwChange(unsigned int newValue) {DcsBios::LED engineCrankSwBuffer(0x74c2, 0x0600, A14);}DcsBios::IntegerBuffer engineCrankSwBuffer(0x74c2, 0x0600, 9, onEngineCrankSwChange); void setup() { DcsBios::setup(); } void loop() { DcsBios::loop(); } These are the errors I am getting... C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:41:24: error: conflicting declaration 'DcsBios::LED selJettBtn' DcsBios::LED selJettBtn(0x7480, 0x0100, 15); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:16:23: note: previous declaration as 'DcsBios::ActionButton selJettBtn' DcsBios::ActionButton selJettBtn("SEL_JETT_BTN", "1", 2); ^~~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:130:24: error: conflicting declaration 'DcsBios::LED fuelDumpSw' DcsBios::LED fuelDumpSw(0x74b4, 0x0100, A6); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:71:23: note: previous declaration as 'DcsBios::ActionButton fuelDumpSw' DcsBios::ActionButton fuelDumpSw("FUEL_DUMP_SW", "1", 31); ^~~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:133:23: error: conflicting declaration 'DcsBios::LED batterySw' DcsBios::LED batterySw(0x74c4, 0x1800, A7); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:100:21: note: previous declaration as 'DcsBios::Switch3Pos batterySw' DcsBios::Switch3Pos batterySw("BATTERY_SW", 47, 48); ^~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:136:26: error: conflicting declaration 'DcsBios::LED apuControlSw' DcsBios::LED apuControlSw(0x74c2, 0x0100, A8); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:103:23: note: previous declaration as 'DcsBios::ActionButton apuControlSw' DcsBios::ActionButton apuControlSw("APU_CONTROL_SW", "1", 49); ^~~~~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:139:33: error: redefinition of 'DcsBios::ActionButton fuelDumpSw' DcsBios::ActionButton fuelDumpSw("FUEL_DUMP_SW", "0", A9); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:71:23: note: 'DcsBios::ActionButton fuelDumpSw' previously declared here DcsBios::ActionButton fuelDumpSw("FUEL_DUMP_SW", "1", 31); ^~~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:142:29: error: redefinition of 'DcsBios::ActionButton ltdRSw' DcsBios::ActionButton ltdRSw("LTD_R_SW", "0", A10); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:77:23: note: 'DcsBios::ActionButton ltdRSw' previously declared here DcsBios::ActionButton ltdRSw("LTD_R_SW", "1", 34); ^~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:145:20: error: conflicting declaration 'DcsBios::LED ltdRSw' DcsBios::LED ltdRSw(0x74c8, 0x4000, A11); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:77:23: note: previous declaration as 'DcsBios::ActionButton ltdRSw' DcsBios::ActionButton ltdRSw("LTD_R_SW", "1", 34); ^~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:148:35: error: redefinition of 'DcsBios::ActionButton apuControlSw' DcsBios::ActionButton apuControlSw("APU_CONTROL_SW", "0", A12); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:103:23: note: 'DcsBios::ActionButton apuControlSw' previously declared here DcsBios::ActionButton apuControlSw("APU_CONTROL_SW", "1", 49); ^~~~~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino: In function 'void onEngineCrankSwChange(unsigned int)': C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:154:6: error: redefinition of 'void onEngineCrankSwChange(unsigned int)' void onEngineCrankSwChange(unsigned int newValue) {DcsBios::LED engineCrankSwBuffer(0x74c2, 0x0600, A14);}DcsBios::IntegerBuffer engineCrankSwBuffer(0x74c2, 0x0600, 9, onEngineCrankSwChange); ^~~~~~~~~~~~~~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:151:6: note: 'void onEngineCrankSwChange(unsigned int)' previously defined here void onEngineCrankSwChange(unsigned int newValue) {DcsBios::LED engineCrankSwBuffer(0x74c2, 0x0600, A13);}DcsBios::IntegerBuffer engineCrankSwBuffer(0x74c2, 0x0600, 9, onEngineCrankSwChange); ^~~~~~~~~~~~~~~~~~~~~ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino: At global scope: C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:154:149: error: redefinition of 'DcsBios::IntegerBuffer engineCrankSwBuffer' void onEngineCrankSwChange(unsigned int newValue) {DcsBios::LED engineCrankSwBuffer(0x74c2, 0x0600, A14);}DcsBios::IntegerBuffer engineCrankSwBuffer(0x74c2, 0x0600, 9, onEngineCrankSwChange); ^ C:\Users\marka\Documents\Arduino\F18Panel\F18Panel.ino:151:130: note: 'DcsBios::IntegerBuffer engineCrankSwBuffer' previously declared here void onEngineCrankSwChange(unsigned int newValue) {DcsBios::LED engineCrankSwBuffer(0x74c2, 0x0600, A13);}DcsBios::IntegerBuffer engineCrankSwBuffer(0x74c2, 0x0600, 9, onEngineCrankSwChange); ^~~~~~~~~~~~~~~~~~~ exit status 1 Compilation error: conflicting declaration 'DcsBios::LED selJettBtn'
  13. Thank you for the help. I'm using a mega though so that workaround sadly won't work. I hoped there might be a way to trigger keypresses via dcs bios as a workaround with the Mega, but sadly not it would seem.
  14. Ok good to know. Thanks for the info mate. Any idea on the throttle lift references?
  15. Awesome, cheers Two more questions.. Is it possible to Code a panel to work with more than one module? So you can code pin 2 to work for gear up on f18 & then add another line that says pin 2 is also gear up on another plane? And I can't seem to find a reference in the DCS bios reference lookup codes for throttle fingerlifts. I wanted to have a 2 way toggle for left and right to switch from cut to idle.
  16. Forgot to ask, do I need to add any extra Code in dcs bios to use analog as digital?
  17. Cheers mate.
  18. Thanks very much. The leds I have come with resistors already pre-soldered on the grounds. So when addressing them I just call them A1, A2 etc.?
  19. Hey guys, quick question. Building my first panel at the moment and gonna use dcs bios. I'm using an Arduino mega and I'm a couple Digital pins short. So wanted to know can I use analog pins for some extra digital pins? If so can these also power some leds? So I can use them for leds on backlit switches?
  20. OK cheers mate. I'll do some more research
  21. I was looking into using relays to do the on-off to on-on & on-off-on to on-on-on conversion in hardware. If I use a 5v relay strip of 16, or two of them, is it safe to run them from the arduino 5v power directly, or would they need their own power?
  22. Ok thanks. I'll check that out. I'll post more when I make a start
  23. Don't know how many yet. I guess I'll come close to maxing out the mega. Ah ok. I found something called unojoy that has mega suppert. Should that do the job?
  24. How would I use this though? Do I download a basic joystick library to the arduino mega and then add this code for each 3 way toggle, or 2 way toggle? Maybe I need some "Arduino 101 tips" Is there a recommended library to download for this?
  25. Thanks very much mate
×
×
  • Create New...