Toggle switch as bu...
 
Notifications
Clear all

Toggle switch as button in keyboard simulation

9 Posts
4 Users
6 Reactions
4,361 Views
(@blackghostd5)
New Member
Joined: 4 years ago
Posts: 4
Topic starter  

I don't know how clear the title was, but what i'm trying to achive is the following: I have 3 toggle switches wired up to my arduino as push buttons. It all works well, if i flip the switch the button gets pushed, if i flip it agin, it releases. My problem is that i want to have an emulated keyboard button press each time that the state of the switch has changed, so if i flip the switch up, there is a button press, and release, and if i flip it agin, another push and release. Does anyone know how i could make that happen trough simhub? I'm using an arduino nano, and i know, i hould be using a Pro Micro, or something with HID support, but thats what i have atm. Any help will be appreciated! (sorry if i can't write, im europian)


   
Quote
(@dafre81)
Active Member
Joined: 3 years ago
Posts: 5
 

Hey BlackGhostD5,

I see you posted this 3 months ago, figured it out already?

I might have a solution.

If you answer me, i will share it  😉 


   
ReplyQuote
(@blackghostd5)
New Member
Joined: 4 years ago
Posts: 4
Topic starter  

@dafre81 Hi! I still have no solution for this, and would be cool to have it work the way i want! You have a solution for this?


   
ReplyQuote
(@dafre81)
Active Member
Joined: 3 years ago
Posts: 5
 

@blackghostd5 

 

first off all, i hope my english is good enough, i'm dutch speaking belgian

second, it would be so nice if simhub simply puts in a toggle switch possibility

 

As we speak, i'm making a button box for ETS2 using a arduino uno

A simple push button works like this, press it ON, release it OFF

A toggle switch doesn't work that way

you have to think that a toggle switch is actually two buttons; OFF-ON-OFF and ON-OFF-ON

so what i did is lying to simhub and my arduino

 

SKETCH SETUP

For 1 toggle switch, i make 2 additional buttons, both on the same pin, one normal logic, and one reversed logic

you will see an error because you are using 2 buttons on the same pin, just ignore it

 

KEYBOARD EMULATION

this is a tricky one

you have to make 2 inputs as wel

when its asking "waiting for input": you go OFF - ON - OFF with your switch

and for the second input you go ON - OFF - ON

for both you use "press type: pressed"

and both assign the same key, example L for lights, just make sure it's the key that you will use in your game

 

It is just a testing fase, buth so far it seems to work

And it is a little bit tricky so i really hope that simhub comes with a easier solution

i hope this will help you, let me know when it's working, or when you have questions


   
PR70 reacted
ReplyQuote
(@dafre81)
Active Member
Joined: 3 years ago
Posts: 5
 

i hope you see here a png file with screen shot


   
PR70 reacted
ReplyQuote
(@dafre81)
Active Member
Joined: 3 years ago
Posts: 5
 

i hope you see here a png file with screen shot


   
PR70 reacted
ReplyQuote
(@dafre81)
Active Member
Joined: 3 years ago
Posts: 5
 

I'm using a toggle switch with LED


   
PR70 reacted
ReplyQuote
(@jeff78s)
New Member
Joined: 3 years ago
Posts: 1
 

Hello,

@DaFrE81 : I registered to thank you for your solution which worked for me.
 
Cheers
 
Jeff
 
 

   
PR70 and DaFrE81 reacted
ReplyQuote
 PR70
(@pr70)
New Member
Joined: 2 years ago
Posts: 1
 

This worked perfectly ! 

For all who struggle with setting the Button input to a key ( getting it recognized) - you need to change state of the toggle really quick (as fast as you can), this worked for me after multiple tries. 

 

Thanks for the solution @DaFrE81. I actually think this is a quite easy solution compared to coding the arduino yourself as are some other solutions. 

 

 


   
ReplyQuote
Share: