Signal switch
Signal switch
Anyone have any idea how to set up a signal light switch that turns off when you move the lever to off? I have put together the switch with the USB controller but have to move the lever twice to cancel the signal lights.
Re: Signal switch
I haven't worked with that specific setup, but is there an option to set the switch position circuitry? The on positions should be opposite to the off position (i.e. normally open vs normally closed); some controllers also give the option to set as a momentary switch, that should work as well.
1.39 combined engine pack now available
1.39 default SCS replacement engine pack now available
MS Flight Sim 2020 - Alpha test team
1.39 default SCS replacement engine pack now available
MS Flight Sim 2020 - Alpha test team
Re: Signal switch
its a real signal light switch. it's either on or off. The game does not recognize off.
-
- Posts: 380
- Joined: 30 Aug 2016 14:00
Re: Signal switch
I think there are threads about this here. I've seen tips about an interface which convert the switch positions into commands for ETS. Left indication with your switch needs to send "toggle left ind." to ETS. The indicator flopping back to center (turning off) must send "toggle left" once more to cancel the turn signal. Hardware cockpit owners have asked SCS for ages to fix the turn signal logic but it seems not so easy for them.
Re: Signal switch
Yeah, that' s what i figured. There is a software developer Spad Nxt (P3D and FSX), and they are working on software to emulate switching for ETS2 and ATS. They are still working on it. I guess I'll have to wait. Cheers.
Re: Signal switch
I worked with Arduino in the past and I made this code for a rocker switch. With a little modification you could use it for signal switch.
I also made one for retarder. Since I have the original switch but game needs either up or down, it got a bit more complicated. Tested only briefly.
Mind you, I have absolutely no idea how to code and seeing this after a year makes me wonder how it actually works.
Code: Select all
#include <Keyboard.h>
const byte pkbrk = 5; //parking brake
bool tbON = true; //to be ON
const byte fshhbeam=6; //flash high beams
void setup() {
pinMode(pkbrk, INPUT_PULLUP);
pinMode(fshhbeam, INPUT_PULLUP);
Keyboard.begin();
}
//Works with each ON OFF "switch", assigned keys can be the same or different. On each manual switch sends the assigned key (only once) and then waits for another manual switch. Not for momentary switches.
void loop() {
if (tbON == true and digitalRead(pkbrk) == LOW) {
Keyboard.press('a');
delay(100); //needed for the game
tbON = false;
Keyboard.release('a');
}
if (tbON == false and digitalRead(pkbrk) == HIGH) {
Keyboard.press('a');
delay(100);
tbON = true;
Keyboard.release('a');
}
//Simulates normal keyboard. For momentary switches.
if (digitalRead(fshhbeam) == HIGH) {
Keyboard.press('j');
}
else
Keyboard.release('j');
}
Code: Select all
/*
You need to move the lever to OFF position before plugging the controller in.
*/
#include <Keyboard.h>
const byte retOFF = 4;
const byte ret1 = 5;
const byte ret2 = 6;
const byte ret3 = 7;
const byte ret4 = 8;
byte ret_pol = 4; //first pin, current position of the lever
byte ret_pol_orig = 4; previous position of the lever
void setup() {
pinMode(ret1, INPUT_PULLUP);
pinMode(ret2, INPUT_PULLUP);
pinMode(ret3, INPUT_PULLUP);
pinMode(ret4, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
if (digitalRead(5) == LOW and digitalRead(6) == LOW and digitalRead(7) == LOW and digitalRead(8) == LOW) {
(ret_pol_orig) = (ret_pol);
(ret_pol) = (retOFF);
}
if (digitalRead(ret1) == LOW) {
(ret_pol_orig) = (ret_pol);
(ret_pol) = (ret1);
}
if (digitalRead(ret2) == LOW) {
(ret_pol_orig) = (ret_pol);
(ret_pol) = (ret2);
}
if (digitalRead(ret3) == LOW) {
(ret_pol_orig) = (ret_pol);
(ret_pol) = (ret3);
}
if (digitalRead(ret4) == LOW) {
(ret_pol_orig) = (ret_pol);
(ret_pol) = (ret4);
}
//Main loop sending signals to the PC.
if (ret_pol > ret_pol_orig) {
Keyboard.press('s');
delay(100);
Keyboard.release('s');
}
else if (ret_pol < ret_pol_orig) {
Keyboard.press('a');
delay(100);
Keyboard.release('a');
}
}
Seasonic SSR-650TD; Intel Core i5-6700K; Gainward GTX 1060 6GB Phoenix GS; 2x Kingston HyperX Fury 8GB; 2x Crucial MX500 2TB; 3x Seagate IronWolf Pro; Corsair Force MP510 960GB; 2x 24" AOC I2481FXH; Windows 10
www.etrusan.net
www.etrusan.net
Re: Signal switch
I've started working on a full steering wheel with the wiper and signal switches, the idea is when you pull the switch up you "press the button" when you pull the switch back to idle you "push the button" again to cancel it.
Using an Arduino Leonardo with the Joystick library https://github.com/MHeironimus/ArduinoJoystickLibrary
Global variables
The switch logic
The `doPressButon()` function
Hope it helps, or give you an idea what to do
PS: Using stuff from a Ford Mondeo MK4
Using an Arduino Leonardo with the Joystick library https://github.com/MHeironimus/ArduinoJoystickLibrary
Global variables
Code: Select all
#define idleSignal 46
/* ... */
int LastSignalV = idleSignal;
int LastSignal = 0;
#define btnSignalRight 1
#define joySignalRight 2
#define btnSignalLeft 2
#define joySignalLeft 1
#define btnHighBeamFlash 3
#define joyHighBeamFlash 3
#define btnHighBeamToggle 4
#define joyHighBeamToggle 4
Code: Select all
int CurrentSignalV = analogRead(pinInputButtonsSignal);
int CurrentButton;
switch(CurrentSignalV) {
case 46 ... 47: // Idle
CurrentButton = 0;
break;
case 320 ... 330: // Turn Right
CurrentButton = btnSignalRight;
break;
case 250 ... 260: // Turn Left
CurrentButton = btnSignalLeft;
break;
case 460 ... 465: // Flash Highbeam
CurrentButton = btnHighBeamFlash;
break;
case 800 ... 950: // Toggle Highbeam
CurrentButton = btnHighBeamToggle;
break;
}
// Turn signals, light toggle
if ((LastSignal == 0 && CurrentButton == btnSignalRight) || (LastSignal == btnSignalRight && CurrentButton == 0) || (LastSignal == btnSignalLeft && CurrentButton == btnSignalRight)) {
doPressButton(joySignalRight);
} else if ((LastSignal == 0 && CurrentButton == btnSignalLeft) || (LastSignal == btnSignalLeft && CurrentButton == 0) || (LastSignal == btnSignalRight && CurrentButton == btnSignalLeft)) {
doPressButton(joySignalLeft);
} else if (LastSignal != btnHighBeamToggle && CurrentButton == btnHighBeamToggle) {
doPressButton(joyHighBeamToggle);
}
// Lights Horn
if (CurrentButton == btnHighBeamFlash) {
Joystick.pressButton(joyHighBeamFlash);
} else if (LastSignal == btnHighBeamFlash && CurrentButton != btnHighBeamFlash) {
Joystick.releaseButton(joyHighBeamFlash);
}
LastSignalV = CurrentSignalV;
LastSignal = CurrentButton;
Code: Select all
void doPressButton(int button) {
Joystick.pressButton(button);
delay(50);
Joystick.releaseButton(button);
}
PS: Using stuff from a Ford Mondeo MK4
Re: Signal switch
If you use Autohotkey you can create script which monitors on/off state. Example here is for parking brake. I try to write more detailed instructions how to set it up. 6Joy14 is your controller ID (6) and 14 is button number. You need to figure that out.
#InstallKeybdHook
6Joy14::
Send {6} ; Should active parking break
KeyWait 6Joy14 ; Wait for the user to release the joystick button.
Send {6} ; When returning toggle to center off position parking brake released
return
#InstallKeybdHook
6Joy14::
Send {6} ; Should active parking break
KeyWait 6Joy14 ; Wait for the user to release the joystick button.
Send {6} ; When returning toggle to center off position parking brake released
return
Re: Signal switch
You can also use Joy2Key for SPST (on/off) switches. If you want to go this way let me know as there’s a little trick to get them to work.
Never argue with idiots. They bring you down to their level and beat you with experience.
Re: Signal switch
I am always interested to hear what trick that is? I think i tried to use Joy2Key sometimes and couldnt get it working so instead i did controller scripts with Autohotkey
Who is online
Users browsing this forum: No registered users and 3 guests