element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Toggle switch to push button switch conversion (Arduino or IC logic)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 62 replies
  • Answers 13 answers
  • Subscribers 397 subscribers
  • Views 7184 views
  • Users 0 members are here
  • push
  • toggle
  • trigger
  • button
  • flight
  • switch
  • arduino
  • simulator
Related

Toggle switch to push button switch conversion (Arduino or IC logic)

silviustro
silviustro over 11 years ago

     I would like to build an interface for a flight simulator consisting on various toggle and trigger switches, unfortunately i can't just simply flip a switch to an ON state and leave the signal like that, i need to send a quick pulse every time you toggle the switch ON or OFF, as if you where to push a button on a keyboard to send that command.

 

     In simple words... i need a toggle switch that will produce one pulse when you flip the toggle switch ON. And a second pulse will be generated when the same toggle switch is flipped to OFF. Here is a GIF to better illustrate that... http://www.desktopaviator.com/Products/Model_2120/2120B.gif

 

     If there is a simpler way of doing this without using an Arduino, like an IC or a special toggle swich, I would like to know, otherwise, I plan on using an Arduino to do this.

 

 

Thank you for your time!

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz over 11 years ago +3 suggested
    Hi Silviu, An easy method to produce pulses is to get a 'quad XOR gate' ic. Connecting one input of a gate to 0V makes a simple buffer which does nothing except delay a signal slightly. Do this with three…
  • shabaz
    shabaz over 11 years ago in reply to silviustro +2 suggested
    Hi Silviu, If you want to do it using an Arduino alone, you will need 80 pins for 40 switches and 40 outputs, so that may be unfeasible. Anyway, below is some pseudocode that will do it for (say) 4 switches…
  • jw0752
    jw0752 over 11 years ago in reply to silviustro +2 verified
    Hi Silviu; I have drawn a schematic and added some notes. . Don't worry about right answers as everyone contributes good ideas. If you have clarifying questions let me know. John
Parents
  • silviustro
    0 silviustro over 11 years ago

    Thank you for your answer Shabaz,

     

    I have to say, i did tough of using a logic gate to produce the signal, tho, when you have 40 toggles you need to wire, it becomes inefficient. A tenth of a nanosecond wouldn't be enough, i'd need something like a half second pulse to trigger the command correctly.

     

    Now, is there a way of doing this with an MCU? preferably an Arduino, (something like, if toggle on, then turn on led for one second, then if toggle off, do the same) I'd test it out with an LED, then replace it with an optocoupler. I have done the reverse, making a push button toggle a motor ON and OFF, but even then, i needed help with the code regarding the buffer of the Arduino. (i think using a delay without a loop would work, wouldn't it? the LED would turn on, and then stay off?)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jw0752
    0 jw0752 over 11 years ago in reply to silviustro

    Hi Silviu,

    I see that you have marked this question closed but I thought I would throw an old fashioned idea at you anyway. If you are able to use DPDT toggles you could hook them up to reverse the polarity of a capacitor. In this way each time the switch is toggled the capacitor would discharge and recharge creating a current of duration depending on the size of the capacitor. I prototyped a small circuit and was able to get an LED to turn on for one second each time the switch was toggled. If this idea fits your need you could save lots of hardware and programming. If you would like a schematic for the little prototype I put together let me know.

    John

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • silviustro
    0 silviustro over 11 years ago in reply to jw0752

    Thank you very much for your diagram John, I will sure test it out!

     

    Now, what do you mean by a NON-Polarized Capacitor? as I have never seen one before, all seem to have a polarization indication on them.

     

    Thank you.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • R_Phoenix
    0 R_Phoenix over 11 years ago in reply to silviustro

    Capacitor - Wikipedia, the free encyclopedia

     

    The top right cap is non-polarized, Ceramic Capacitor. If you use a polarized one, like an Electrolyte, you will pop it when you revers the polarity.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • silviustro
    0 silviustro over 11 years ago in reply to R_Phoenix

    Wow, ok, big-ass ceramic capacitors, that's better, thanks....haha.

     

    In the region i live in i have never seen those big ceramic capacitors, just small ones, i'll have to talk to my supplier to get some, thanks. also, how would the circuit change if i replace the switch with a SPDT?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • R_Phoenix
    0 R_Phoenix over 11 years ago in reply to silviustro

    Doesn't have to be a "big ass one" lol.

     

    Anyways, With a mom-off-mom switch, you wouldn't need the capacitor at all. The LED would only be one as long as you hold the switch in the "ON" or "OFF" position and off, when you let go. But I'm not sure exactly what your doing so it's just another suggestion. may or may not be what your looking for.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • silviustro
    0 silviustro over 11 years ago in reply to R_Phoenix

    Oh! Oh! you mean "momentary toggle switches" those work great as well,  but i wanted a normal toggle switch to act as the trigger, so the capacitor is needed indeed, in the case of a mom-off-mom, no, of course not, it would be like a normal push button.

     

    I am just a little confused as to how the cap is wired... and if you need a DPDT or if a normal toggle switch would do the trick as well.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • R_Phoenix
    0 R_Phoenix over 11 years ago in reply to silviustro

    Then yes, you will need DPDT.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jw0752
    0 jw0752 over 11 years ago in reply to silviustro


    Hi Silviu,

    We seem to have sparked a lively discussion. Reference your question about the non-polarized capacitors you can buy them or make them. They are used in audio speaker crossover circuits. I think the Radio Shack used to have them in stock. You can make them by placing two polarized capacitors back to back. For example if you take two 100uf 25 volt electrolytics and connect the negative leads together the two positive leads become 50uf 50 volt non-polarized. You will notice that by connecting the caps in series we produce a new cap with half the capacitance and double the voltage. I would recommend that you use caps that have voltage ratings larger than your working voltage. For example if you are using 35 volts in your circuit then make your non-polarized cap from 50 volt electrolytics. If you are going to use this circuit you will have to use a DPDT switch. I see that there have been some ideas about using center off and momentary toggles. I think you will find that a standard DPDT is cheaper than the specialty momentary switches. These are just general ideas as I do not know much about your application and working parameters.

    John

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • silviustro
    0 silviustro over 11 years ago in reply to jw0752

    Hi John,

     

    Indeed, we seem to have, hahaha. The idea of connecting 2 capacitors together to make a non-polarized one deserves a try!, as for the DPDT switch, my confusion lies in the fact that there are different types pf DPDT switch (http://www.terrylove.com/forums/attachment.php?attachmentid=19947&d=1366455685) I guess you are referring to a on-off-on switch (the one on the upper right corner) right?. As for the application, turning a led on for a second would work perfectly, no other details needed, just that. Thank you for all your feedback, it has been really useful.

     

    Silviu.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • jw0752
    0 jw0752 over 11 years ago in reply to silviustro

    Hi Silviu,

     

    Actually my design is for a standard DPDT toggle switch with only side to side, no center off. I call the one you described DPDTCO. Once the switch is flipped from one side to the other the current flows as it charges the capacitor. Since we are dealing with direct current the flow stops as soon as the capacitor is charged up. The DPDT switch, if flipped to the other side, will reconncect the capacitor to the circuit reversed. This will allow the charge that is in the capacitor to exit and a new reversed charge to flow into it. I think the use of a center off switch would not work as well as the charge would have time to leak out while the switch is in the center position. While you would get a pulse each time you switched from the center position it would only be half the duration of using the switch the way I described it. As far a the actual style of the DPDT switch it can be any kind from a rocker to a slide. One more note, in my original post I mentioned that point "one" could be used to determine the up or down position of the toggle. The sensing of this point must be high impedance or you will be putting a resistance accross the capacitor when the switch is in one position.

     

    John

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • billpenner
    0 billpenner over 11 years ago in reply to silviustro

    adding to the comments by shabaz ;

     

    The following might of help. Since you are using many switches and apparently need them to be independent,

    you could put all the resistors,capacitors and ICs on a PC board to simplify wiring.

    The ICs are quad XOR gates so each IC will handle four switches.

    The pulse width can be adjusted with R8 and C3. Using the values shown will produce about 1/2 second. The capacitors can be ceramic, which is very small.

    The ICs are available in both the standard dual inline and small form factor.

    I don't know what you are going to drive with the output, so I am not sure if the IC will handle the necessary current.

    Could you let us know where the output of this conversion goes?

     

    Bill

     

    image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • billpenner
    0 billpenner over 11 years ago in reply to silviustro

    adding to the comments by shabaz ;

     

    The following might of help. Since you are using many switches and apparently need them to be independent,

    you could put all the resistors,capacitors and ICs on a PC board to simplify wiring.

    The ICs are quad XOR gates so each IC will handle four switches.

    The pulse width can be adjusted with R8 and C3. Using the values shown will produce about 1/2 second. The capacitors can be ceramic, which is very small.

    The ICs are available in both the standard dual inline and small form factor.

    I don't know what you are going to drive with the output, so I am not sure if the IC will handle the necessary current.

    Could you let us know where the output of this conversion goes?

     

    Bill

     

    image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 11 years ago in reply to billpenner

    I need this type of circuit for a pipe organ, but the stop switch is magnetic reed spst.   We need to control the stop input of a sound module which uses pulse on and pulse off.  Any mods to this circuit?  

    Chaim

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 11 years ago in reply to Former Member

    Hi Chaim, can you provide a drawing?  I don't know much about organs.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to D_Hersey

    Hi

    The stop switch  is nothing more than a big slide switch which uses  an attached bar magnet  sliding in close proximity to a enclosed reed switch.  The switch does nothing more than to supply 12 or so volts dc to an input board which eventually will turn on the mechanics and electronics of a pipe chest.     My problem is we have a sound module where the stops are turned on and off by a momentary push button contact.  There were external terminals added to do the same function by remote wiring.   The late organs are control the stops or voices by this method even with these stop knobs.   But they are nothing more than momentary contact switchs which activate when the knob is pulled or deactivated when the knob is pushed, and is on a spring return with an indicator lamp inside.    We want to control this box with the original stop mechanisms on the organ console.  So far I cannot figure a circuit which would be able to give me 2 states--an on state and an off state.   The on state is easy, it is when the voltage is removed how does that get translated to a pulse to trigger the box to shut the stop off?  The pulse width can be 500ms

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • D_Hersey
    0 D_Hersey over 11 years ago in reply to Former Member

    Still not clear on this, could this be your ticket?

     

    http://www.fairchildsemi.com/ds/MM/MM74C221.pdf

    http://www.fairchildsemi.com/an/AN/AN-138.pdf

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to D_Hersey

    Thanks Don.  I will experiment with this also.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billpenner
    0 billpenner over 11 years ago in reply to Former Member

    RE: My last response to you. I was a bit confused since we have two related questions going at the same time. Directly related to your question;

    The  suggestion by Peter is very good. values of the resistors and capacitors will determine the pulse width. In your case, What is the voltage/current needed at the output and what is the pulse width?

    Top resistor  into the IC is not normally needed.

    Hope this clarifies it a little.

    Bill


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to billpenner

    Hi 

     

    We will experiment with that circuit also.   The  problem is the voltage going to the stop swtich is about 16 vdc.   The output is better driving a relay as the contacts on the sound module terminals have different commons, but I believe the voltage is 5v.  But its best to isolate this from the sound module switching via a relay.   The output of the switch actually goes to a terminal board and eventually goes to switching IC input board then on to electronics associated with the pipe valves.   We don't want to change this circuit as it leaves the option open to return back to real pipes. Thanks again.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • billpenner
    0 billpenner over 11 years ago in reply to Former Member

    I understand the need for isolation. I would be concerned about the cost for 40 relays. Also you wouldn't have the pulse without some kind of circuitry.

    Possibly you could use an opto-coupler for isolation. They are pretty cheap,  especially in the quad version. The translation would not be needed in that case.

    If I were faced with this project, I would make a PC board which had 4 or (8)  inputs. With ex-or gate(s). I would then make 10 (5) PC boards for the complete system. I think this would be the most economical solution for you.

    Good luck on the project.

    Bill

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to billpenner

    good idea--now to search for  parts.  No Radio Shacks here in the Philippines.

    chaim

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 11 years ago in reply to Former Member

    Thanks all.  The circuit works fine with added reed switch for off sense.   The indicator LED loads the circuit and is not needed and upsets the logic anyway.   We could not find a simple satisfactory system where the stop is pulled high--sending a pulse and when pushed to 0 producing another pulse.  The output is connected to an opto-isolator which briefly pulses the  sound module box.  WE notice also when the circuit is depowered and repowered the circuit will always revert to "off" position.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube