I'm working on a budget simulator build, and I'm planning on have a selection of switches or devices that work in a "Toggle" manner, i.e. latches in the on position until moved to the off and vice versa.

The issue I face with this is that most of the commands I want to control are normally controlled by a keyboard, and expect a momentary input. I'm planning on using an old keyboard as my input device, taking it apart and soldering leads onto each of the key contacts. Im hoping for 2 functionalities:

1) When the toggle switch is flipped from off to on ONLY, allow a momentary connection across the keyboard contacts.

  • found this link but uses double pole switch, need to be able to use single pole enter image description here

2) When the toggle switch is flipped from off to on AND from on to off, allow a momentary connection across the keyboard contacts.

  • The link above has a solution but same issue as above, plus it requires relays, hoping to do this with small, inexpensive components

enter image description here

  • This link i think has a solution, but I know nothing about logic gates and my electrical expertise is limited t best, trying to figure what connects to the 3 leads (assuming the arrow is ground, the left is the positive contact and the right is the negative contact?).

enter image description here

I tried simulating on falstad.com and only get an inital pulse on, nothing off or on subsequent flips. The voltage on the two comparator legs of the gate both read the same voltage.

enter image description here

Any help would be much appreciated

  • 2
    \$\begingroup\$ Welcome to EE.SE, James. Can you post images into your question so that we don't have to follow three links just to understand it? \$\endgroup\$ – Transistor Aug 27 '19 at 16:02
  • 3
    \$\begingroup\$ I think the easiest way to do this would be to route the buttons into an Arduino and have the Arduino hooked up as a USB HID keyboard to the computer. Add all the logic you want at that point. \$\endgroup\$ – Ron Beyer Aug 27 '19 at 16:07
  • 1
    \$\begingroup\$ Arduino USB Keyboard Reference \$\endgroup\$ – Ron Beyer Aug 27 '19 at 16:15
  • \$\begingroup\$ Updated with pictures, didn't include the first time as it makes the post quite long. \$\endgroup\$ – James Aug 27 '19 at 16:47
  • \$\begingroup\$ Ron - I appreciate the idea, was something i had looked at in the past. I only have brief experience with arduino so would take some learning. I was thinking that might also be quite a bit more expensive than some resistors, caps and gates? I'm talking in the range of 30-40 inputs, not sure what size arduino i would need, and when i would start needing to build a matrix, etc. \$\endgroup\$ – James Aug 27 '19 at 16:52

The last solution you have linked can work as expected for your application. I simply ran it through falstad with normal XOR gate and it works as expected. But XOR gate with Schmidt trigger input is highly recommended.

enter image description here

When the toggle switch is flipped from off to on AND from on to off, allow a momentary connection across the keyboard contacts

Any level change on the input pin (OFF to ON or ON to OFF) creates a short pulse on the output Pin (output of XOR Gate) The output can be then used to drive a MOSFET or other similar component to close the keyboard contacts.

The pulse width can be varied by varying the value of \$R1\$ and \$C1\$. Exact values of \$R1\$ and \$C1\$ can be attempted to calculate based on datasheet of the EXOR gate used. as of now, trial and error method should work.

A simple LTSpice simulation

Green is input voltage, RED is voltage across capacitor and Blue is the output voltage.
enter image description here

| improve this answer | |
  • \$\begingroup\$ Thanks Umar. I added an image from my Falstad simulation in the original post. I cant get it to pulse more than once. Am i missing something? \$\endgroup\$ – James Aug 27 '19 at 19:58
  • \$\begingroup\$ Thanks again, not sure why it wont replicate on falstad but worth a shot in reality for a couple bucks. Appreciated! \$\endgroup\$ – James Aug 28 '19 at 12:10
  • \$\begingroup\$ Please add a voltage Source in falstad. Set frequency to 10 Hz, a square wave signal. It will work \$\endgroup\$ – User323693 Aug 28 '19 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.