Jump to content

Rotary Encoder W/Switch, LED and Arduino Help Please


Kenpilot

Recommended Posts

I'm building the Intercom Panel for the A10 and this is how I'm wanting to build it, but need some help. I'm using rotary encoders with switches for the volume knobs, and an Arduino Mega to be used with DCS Bios. I want to wire the knobs so that they are "turned on" only when I push the encoder switch, and turned off when I push it again. Along with this, I'd like to wire an LED backlight for the panel to light up when I push the switch, showing me that volume knob is "on" or "active", and then turned off when I push the switch again. So how do I wire the rotary encoder with switch (GND, +, SW, DT, CLK), the LED (+,-) and Arduino Mega. Thank you for any help! 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Link to comment
Share on other sites

Hi Ken,

You need 4 pins for each of the functions: 2 digital pins for the rotary, 1 digital pin for the switch and 1 pin for the corresponding LED. All can have a common pin to the GND signal.

The (+) mostly is not necessary as the positive voltage is provided from the digital pins (internal pullup). Some rotaries do have (+) pin, that is to be connected to the Arduino 5V rail.

For the DcsBios part you may work with the "action button" function and  "state machines".

 

Regards, Vinc 


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Hey Vinc! Thanks for the response. Unforunately I'm not familiar with how to use the "action button" function and "state machines" in DCS Bios. The only thing I know how to do is copy and paste the sketch language from DCS Bios to the Arduino. I don't know what the coding means or how to write my own. Do you know of any tutorials or videos for beginners that would hep me understand them so I can figure this out?

 

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Link to comment
Share on other sites

Hi Ken,

For the actionbutton function have a look into the below linked DcsBios documentation. Scroll down and find some examples. To make it short, an actionbutton is a pushbutton that can toggle between ON and OFF. That's what you need to enable or disable the respective rotary by its pushbutton.

https://dcs-bios.readthedocs.io/en/latest/code-snippets.html

A state machine is a piece of code that enables you to switch between several known states to do something. For your application a dedicated rotary should be responsive or not. That already are two states. So the rotary's pushbutton may be programmed to send either the ON or the OFF state of the respective rotary to DcsBios. 

You than read in either 1 or 0 into a variable and can use an if-else loop or case-switch to activate or de-activate the rotary.

 

 

Edit: The solution is simpler after I had a detailed look into Bort, because we have the opportunity to use the Mute/Unmute function for the Intercom Panel switches. So the "state machine" is already provided to us by DcsBios.

Example for the INT switch and rotary encoder:

 

// ----- INT Un-Mute input and output, INT volume adjustment -----
DcsBios::ActionButton intIntUnmuteToggle("INT_INT_UNMUTE", "TOGGLE", 10); // INT switch on pin 10 for the INT Un-Mute switch
DcsBios::RotaryEncoder intIntVol("INT_INT_VOL", "-3200", "+3200", 11, 12); //  INT volume rotary is connected to pins 11 and 12
DcsBios::LED intIntUnmute(0x1194, 0x8000, 13); //  a LED shows if the volume adjustment is active

That's all for one of the Intercom Panel switches.

 

Regards, Vinc

 

 

Intercom_example_01.ino


Edited by Vinc_Vega

Regards, Vinc

real life: Royal Bavarian Airforce

online: VJS-GermanKnights.de

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Thanks so much Vinc!!! I appreciate you taking the time to look that up and send me the sketch for it. I'm still going to check out the link you sent as well to try and educate myself on this stuff. I'm going to try this out in the next few days and hopefully get it working. Thanks again!! :notworthy:

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Link to comment
Share on other sites

Posted (edited)

It worked!! Thanks again Vinc!! 

 


Edited by Kenpilot

Windows 10

ASRock Z370 Extreme4 LGA 1151 (300 Series) MOBO

intel i7-8700k (Not overclocked)

16 GB Ram

EVGA GeForce GTX 108ti SC Black Edition

SSD

Trackir

Link to comment
Share on other sites

  • Recently Browsing   0 members

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