Signal switch

User avatar
marvix
Posts: 113
Joined: 27 Feb 2014 18:23
Location: Hanover, MB

Signal switch

#1 Post by marvix » 26 Mar 2019 01:07

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.
User avatar
Robinicus
Posts: 2562
Joined: 26 Aug 2018 13:02

Re: Signal switch

#2 Post by Robinicus » 26 Mar 2019 02:21

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.
User avatar
marvix
Posts: 113
Joined: 27 Feb 2014 18:23
Location: Hanover, MB

Re: Signal switch

#3 Post by marvix » 26 Mar 2019 02:44

its a real signal light switch. it's either on or off. The game does not recognize off.
Soilingcomic
Posts: 380
Joined: 30 Aug 2016 14:00

Re: Signal switch

#4 Post by Soilingcomic » 26 Mar 2019 11:37

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.
User avatar
marvix
Posts: 113
Joined: 27 Feb 2014 18:23
Location: Hanover, MB

Re: Signal switch

#5 Post by marvix » 26 Mar 2019 11:51

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.
User avatar
Etrusan
Posts: 651
Joined: 04 Sep 2014 15:29
Location: Brno, Czech Republic
Contact:

Re: Signal switch

#6 Post by Etrusan » 26 Mar 2019 15:41

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.

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');

}
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.

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');
      
          }
    
}
Mind you, I have absolutely no idea how to code and seeing this after a year makes me wonder how it actually works.
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
User avatar
MPKaboose
Posts: 15
Joined: 21 Apr 2018 06:24
Location: Romania

Re: Signal switch

#7 Post by MPKaboose » 02 May 2019 18:16

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

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
The switch logic

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;
The `doPressButon()` function

Code: Select all

void doPressButton(int button) {
  Joystick.pressButton(button);
  delay(50);
  Joystick.releaseButton(button);
}
Hope it helps, or give you an idea what to do

PS: Using stuff from a Ford Mondeo MK4
Rymy_Eetu
Posts: 37
Joined: 29 Nov 2017 17:51
Contact:

Re: Signal switch

#8 Post by Rymy_Eetu » 13 Feb 2020 06:19

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
User avatar
natvander
SCS Software
Posts: 2991
Joined: 01 Feb 2015 01:42
Location: NSW, Australia

Re: Signal switch

#9 Post by natvander » 13 Feb 2020 06:30

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.
Rymy_Eetu
Posts: 37
Joined: 29 Nov 2017 17:51
Contact:

Re: Signal switch

#10 Post by Rymy_Eetu » 13 Feb 2020 16:22

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
Post Reply

Return to “Other”

Who is online

Users browsing this forum: No registered users and 3 guests