Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

simple switch held length time

Status
Not open for further replies.

computer

New Member
Hi,

I'm looking for a simple circuit that will basically detect if a button is pressed or is held down.

If the button is pressed then released quickly (<1sec) it should make one output high for about a second, and if it is pressed and held, after a second another output should go high and stay high until button is released.

Please help me with a circuit for this. After messing around with CrocClips I can't find a simple way to do it :/

Thanks
 
I would do it with a microcontroller. PIC and Atmel. Does it have to be
decrete compnents? Is this 3VDC or 5VDC?

The Atmel Tiny11 is cheap ($.50), has 6 IO pins. But you need a programmer and compiler. I do not have any Tiny11 chips, but I can write the code for you if you want to get a programmer.
 
computer said:
It's gonna be on 5V. I hope'd against using microcontrollers and just some simple 555 capacitor logic gate circuit or something to keep it simpler.

I have to order a tube of the Tiny11 today or tomorrow. Let me know if you change your mind :) For me, I think a PIC or Atmel is simpler. Rather edit than calculate and wire. There are a number of good guys on this board. So sure you will get an answer. Not sure if with a 555 though..
 
I am not the PIC expert but have heard enough about them to encourage you to look closely at using a PIC or similar microcontroller. It will allow you to make changes relatively easily. It's likely to be the least expensive if you allow yourself to write off any investment (modest) in hardware and learning over a long period of time.

A more hard wired solution is possible. A circuit that generates a pulse to start the operation of a 555 timer for one second could be made. It would have to ignore the state of the pushbutton after that. That timer could close a contact for the one second then open. That contact could be in parallel with the pushbutton so that the circuit is completed for one second or as long as the pushbutton is held - whichever is longer. On opening of the pushbutton the circuit would reset to allow the pushbutton to operate the timer again.

Purchasing a timing relay might also do the trick but they are expensive. I purchased one last year that would operate on the coil being energized then time out. It would reset when power was removed.
 
Here ya go.
 

Attachments

  • switch_timer.png
    switch_timer.png
    16.5 KB · Views: 396
I just built it on Croc Clips. Doesn't seem to work though. Pressing the button for any length of time just results in the bottom light coming on. I built it correctly as far as I can see...
 

Attachments

  • updown_timer.jpg
    updown_timer.jpg
    13.1 KB · Views: 393
computer said:
I just built it on Croc Clips. Doesn't seem to work though. Pressing the button for any length of time just results in the bottom light coming on. I built it correctly as far as I can see...
Hmmmm....
I sim'ed it in LTSpice, and it worked for me.
Let me see if I understand you.
If I press the button for 100millisecs, the top output goes high for a second, but the bottom output stays off. If I press the button for 3 seconds, the top output goes high for a second, and as it goes off, the bottom output goes high for 2 seconds.

Is your 555 triggering?
 
No, I don't think it is. I'll have a bit more of a play tomorrow. The thing is I don't want the "quick press" output to trigger for the first second of the long press. It needs to be one or the other. I was thinking of maybe some sort of falling edge triggered thing. So as the button is pressed it starts counting to a second, if it reaches a second it triggers the "button held" output if released before the second elapses it pulses on the "quick press" output.
Make sense?
 
computer said:
No, I don't think it is. I'll have a bit more of a play tomorrow. The thing is I don't want the "quick press" output to trigger for the first second of the long press. It needs to be one or the other. I was thinking of maybe some sort of falling edge triggered thing. So as the button is pressed it starts counting to a second, if it reaches a second it triggers the "button held" output if released before the second elapses it pulses on the "quick press" output.
Make sense?
It works the way you want it to. Below, I depressed the switch for 2.5 seconds, repeating every 4 seconds.
 

Attachments

  • switch_timer_waves.png
    switch_timer_waves.png
    7.8 KB · Views: 360
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top