Purzel Posted February 5, 2023 Posted February 5, 2023 Hi folks, I'm new to arduino/IDE/coding. I want to connect a 10k potentiometer to my arduino-board (micro pro) to get my "HUD-brightness" (F/A-18C) working with it. It's connected and powered via USB to my pc. In the reference they say: Zitat Connect one outer pin of the potentiometer to the supply voltage, the other outer pin to ground, and the middle pin (“slider”) to an analog input pin on your Arduino board. This is my arduino-layout: I've connected - one outer pin to GND, - the middle "slider" pin to an analog pin (A9), but I don't know where there power-supply is they mentioned. Can anyone point me the right pin? I've tried all black (Power) marked pins (exept the GND-pins), but when I turn the potentiometer, the arduinos fuse shuts off the board until I turn back the pot. Thx! Greetings Purzel
No1sonuk Posted February 5, 2023 Posted February 5, 2023 It SHOULD be VCC. That's the power rail of the processor. Have you tried a different pot? You might have a faulty one that's shorting the power supply.
Purzel Posted February 5, 2023 Author Posted February 5, 2023 I've connected it as described, but it's not recognised by joy.cpl ( < type in windows search)
Purzel Posted February 5, 2023 Author Posted February 5, 2023 This is the arduino-code I'm using: // Version 2.0 ACHTUNG! - - - - BEIM HOCHLADEN DES CODES AUF DAS ARDUINO-BOARD DARF DCS-BIOS NICHT LAUFEN! #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <Joystick.h> bool state = false; //LANDING GEAR-HANDLE LIGHTs - name of the function that is called, copy from DCS BIOS, CNTRL REF, F18 // CHANGE PIN NUMBER FOR YOUR LED //DcsBios::LED gearLever(0x7478, 0x1000, 0); // All "LED in gear handle"-codes to test DcsBios::LED landingGearHandleLt(0x7478, 0x0800, 0); //Working //DcsBios::LED gearDownlockOverrideBtn(0x7478, 0x4000, 0); //DcsBios::LED emergencyGearRotate(0x7478, 0x2000, 0); // DcsBios::LED gearSilenceBtn(0x7478, 0x8000, 0); DcsBios::LED hookLever(0x74a2, 0x0100, 1); // DcsBios::LED hookLever(0x74a2, 0x0100, 1); //Hook alternative code // Connect one outer pin of the potentiometer to the supply voltage, // the other outer pin to ground, // and the middle pin (“slider”) to an analog input pin on your Arduino board. DcsBios::PotentiometerEWMA<5, 128, 5> hudSymBrt("HUD_SYM_BRT", A9); // HUD potentiometer //DcsBios::RotaryEncoder hudSymBrt("HUD_SYM_BRT", "-3200", "+3200", 8, 9); // HUD rotary enconder alternative? //Joystick_ joystick; Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_GAMEPAD, 12, 0, // Button Count, Hat Switch Count false, false, false, // X and Y, but no Z Axis false, false, false, // No Rx, Ry, or Rz false, false, // No rudder or throttle false, false, false); // No accelerator, brake, or steering void setup() { DcsBios::setup(); // Initialize switch or light Pins // Tells if the pin is an input / output // INPUT or INPUT_PULLUP for button, OUTPUT for LED, steppers, etc. // pullup enables on board pullup resistor to prevent button floating pinMode(1, OUTPUT); // Will be used in future for Hook-LED pinMode(0, OUTPUT); // LandingGear LED pinMode(2, INPUT_PULLUP); // LandingGear Switch pinMode(3, INPUT_PULLUP); // Hook Switch pinMode(4, INPUT_PULLUP); // Unused pinMode(5, INPUT_PULLUP); // Unused pinMode(6, INPUT_PULLUP); // Unused pinMode(7, INPUT_PULLUP); // Unused pinMode(8, INPUT_PULLUP); // Unused pinMode(A9, INPUT); // HUD Poti 1 (Ohne Pullup??) pinMode(10, INPUT_PULLUP); // Unused pinMode(11, INPUT_PULLUP); // Unused // Initialize Joystick Library Joystick.begin(); } int keyState = false; void loop() { DcsBios::loop(); // LandingGear Switch TOGGLE 1 ON/ON (2) WAY, if (digitalRead(2) == LOW) // THIS TELLS WHICH PIN ON THE ARDUINO IS BEING READ // PULLED TO GROUND {Joystick.setButton(0, HIGH);} // THIS NUMBER IS THE BUTTON ON THE VIRTUAL JOYPAD SO 0 HERE EQUALS 1 ON JOYPAD else {Joystick.setButton(0, LOW);} if (digitalRead(2) == HIGH) {Joystick.setButton(1, HIGH);} else {Joystick.setButton(1, LOW);} // Hook Switch TOGGLE 1 ON/ON (2) WAY, if (digitalRead(3) == LOW) // THIS TELLS WHICH PIN ON THE ARDUINO IS BEING READ // PULLED TO GROUND {Joystick.setButton(2, HIGH);} // THIS NUMBER IS THE BUTTON ON THE VIRTUAL JOYPAD SO 0 HERE EQUALS 1 ON JOYPAD else {Joystick.setButton(2, LOW);} if (digitalRead(3) == HIGH) {Joystick.setButton(3, HIGH);} else {Joystick.setButton(3, LOW);} /* PUSHBUTTON, DIGITAL READ = ARDUINO-PIN 3 = PIN AUF ARDUINO, DER ABGEFRAGT WERDEN SOLL if (digitalRead(3) == LOW) // PIN 3 {Joystick.setButton(2, HIGH);} // DIESE NUMMER IST DIE TASTE AUF DEM VIRTUELLEN JOYPAD, ALSO IST 2 HIER GLEICH 3 AUF DEM JOYPAD else {Joystick.setButton(2, LOW);} // PUSHBUTTON, DIGITAL READ = ARDUINO-PIN 4 = PIN AUF ARDUINO, DER ABGEFRAGT WERDEN SOLL if (digitalRead(4) == LOW) // PIN 4 {Joystick.setButton(3, HIGH);} // DIESE NUMMER IST DIE TASTE AUF DEM VIRTUELLEN JOYPAD, ALSO IST 3 HIER GLEICH 4 AUF DEM JOYPAD else {Joystick.setButton(3, LOW);} }
Vinc_Vega Posted February 5, 2023 Posted February 5, 2023 Did you try to separate DCS and joystick related parts of your program? Comment all joystick related commands and try the DCS-Bios part first. Than you may see your potentiometer. Use a 10kOhm poti, and yes, that input doesn't need internal pullups. If that works for you, try to bring back the joystick part of the program. Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
No1sonuk Posted February 5, 2023 Posted February 5, 2023 The pot won't be seen by joy.cpl because you've set it up for use in DCS-BIOS, not as a joystick axis. Try this: DcsBios::Potentiometer hudSymBrt("HUD_SYM_BRT", A9); You don't need the pinMode statements for I/O only used by DCS-BIOS - it does that automatically. AND everything I've read says you don't need it at all for analogue pins as it's automatically set when the analogRead function is called. Also remember that pins 0 and 1 can't be used for normal I/O on ATMega328 Arduinos such as the Uno and Nano. It should be OK for the 32u4 devices like the Pro Micro. If you want it to be aircraft-specific, you could do it all in DCS-BIOS, like this: #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" DcsBios::Switch2Pos hookLever("HOOK_LEVER", 3); DcsBios::Switch2Pos gearLever("GEAR_LEVER", 2); DcsBios::Potentiometer hudSymBrt("HUD_SYM_BRT", A9); DcsBios::LED landingGearHandleLt(0x7478, 0x0800, 0); DcsBios::LED hookLever(0x74a2, 0x0100, 1); void setup() { DcsBios::setup(); } void loop() { DcsBios::loop(); }
Purzel Posted February 5, 2023 Author Posted February 5, 2023 Thank you for your excellent help! Now i can go ahead and get my Deskpit done... THANK YOU ALL!
Recommended Posts