SPST switch and ACC...
 
Notifications
Clear all

SPST switch and ACC ignition

3 Posts
2 Users
0 Reactions
2,814 Views
(@plebre)
New Member
Joined: 4 years ago
Posts: 1
Topic starter  

Hi,

I have this DYI button box with a SPST switch that I am using to control the ignition function of Assetto corsa competizione. 

The problem is that the switch when in ON position give a continuous signal from  the arduino micro. So to turn on the ignition I have to push the switch ON and then OFF so the game recognize the command. 

After some research found this topic on the arduino forum 

https://forum.arduino.cc/t/serial-println-after-pushing-a-button/178911

It's seems that the shown code make the arduino send a single print from the SPST switch. 

I am a noob with the program code and don't have a clue where to add it on the simhub sketch. 

Can you help me?

  • Thanks in advance.

   
Quote
(@joeblow87)
New Member
Joined: 1 month ago
Posts: 2
 

Here is how I tackled this problem when building my own button box.

Cars in ACC have some functions that you want to toggle (off - on), like ignition, starter, wipers, hazards etc.

The game, however, requires a keystroke for these functions (off - on - off) this is the typical logic of a keystroke or a push button. This makes the use of a 2-position toggle switches quite tricky.

So, to quickly outline the problem, you have a 2-position toggle switch, and you want it to act like a keystroke. Therefore, we need to simulate a keystroke using a 2-position toggle switch.  

I defeated this conundrum with arduino uno/nano controllers, toggle switches, and relay modules for the controllers. I use the controller to activate the relay module for only .2 seconds. This makes the logic of the circuit go from off to on to off again very quickly, essentially simulating a keystroke. 

I then wired the relay modules into a generic keyboard encoder. the keyboard encoder is my interface between the game and my arduino controllers that are performing the magic of keystroke simulation with 2 position toggle-switch hardware inputs. 

Basically, you want to input a signal into your arduino with the toggle switch, then use code to activate the relay module for that switch for .2 seconds only, like a pulsed "ON" and you do this every time you change the on/off state of your toggle switch. When you turn the switch on, the relay fires for .2 seconds, the same for when you turn the switch off. 

Chat GPT can write this code for you if you can properly communicate to it what you are trying to do.

Then you just wire your relay modules into your keyboard encoder along with all of your other buttons and rotary encoders. (the rotary encoders are another story, but I essentially got them to do the exact same thing) 

If you've done it correctly, you can open notepad on your PC and watch your toggle switch print a character every time you changed its position. I assigned my toggles to the keyboard letters ABC&D (4 switches) in the software that came with the keyboard encoder.  When I throw my toggle switch up the letter "A" appears once, when I throw the switch down the letter "A" appears again once more, exactly as if I had been pressing the "A" key on a keyboard. 

Then you just set up your controls in ACC the same way you normally would. Viola.

 

the code is saved on my shop PC. if anyone would like it, let me know I'll paste it right here.  

 


   
ReplyQuote
(@joeblow87)
New Member
Joined: 1 month ago
Posts: 2
 

removed link

heres a project I just put together for rotary encoders with a relay interface for reference. 


   
ReplyQuote
Share: