button to do 2 different task depending on how long it's pressed

Status
Not open for further replies.

snaggy

New Member
Here what I need: a button that as soon as it's pressed sets HIGH something, then after 3 seconds turns that LOW and turns HIGH a second line. As soon as it is released, both must go low.

exact timing is not important, and I'd like to do it with few components..
I tried with 2 opamp and a transistor, plus a lowpass filter for timing... it works partly but when you release the button it doesn't go LOW immediately (since the capacitor discharges slowly..) besides I know there must be a much more elegant and easier way!

thanks!
 

Attachments

  • circuit.png
    20.3 KB · Views: 168
Have you thought of making the pushbutton supply the Vcc to the rest of the circuit? That would kill everything when you let off. Then there's the idea of a DPDT switch using one set of contacts to dump the cap at release time.
 
Theory:

At the input of a positive signal, the delay cap at the base of Q2, will charge up placing a neg. signal at the base of Q2, to keep it at turn off when the input goes high, after some time Q1 will turn on and LED1 will light up as RC timer circuit is charging up, at the same time neg. going signal will be steered through the diode to keep Q2 turned off, as RC is fully charged then Q1 will turn off and the continuous positive input signal will be applied to the base of Q2 to keep it on continually. When the input is released then Q2 will shut off as well.

This is only in the theoretical stages, prototyping and testing would need to be done to see what changes would need to be made.
For instance the RC timer should be seperate from the bias of Q1, so Q1 has its proper bias and the RC timer interacts with it.
At the moment the base bias for Q1 is determined by the RC itself, not a good idea.

Also this will be a slow turnoff of LED1 due to RC working in a logarithmic way, more circuitry design would bew needed to make it turn off fast. As well as discharging the RC system.

This is just a preliminary idea, only..


 
Last edited:
timer

Here is one that might work. After re-reading your post however there is one problem. The 3 second timer will not reset when the push button is released. It will continue to time out for 3 seconds. Does that matter? Let me know if it does and I'll have another look.
 

Attachments

  • pb timer.GIF
    26.7 KB · Views: 176
Last edited:
i couldnt get what you exactly want to do wit this? if you need some thing like a long press to set it and a short press to relase it can be done by ocunters. on the 1st post you mentioned it will turn on two out puts depends on the length of the time the switch is pressed, its not clear.

for example if its pressed for 3sec it will turn out put#1 to high, and if it will pressed for 1sec will make output#2 to high? or you need it to hapen one after another?

if you can post a timing diagram it wil be much easy to get your idea.
 
I think what he is after is like how a computer keyboarde works, you press one key, and it prints one character, then as you continuously keep it pressed for a set amount of time, then the character repeats itself, that way one input switch is able to perform 2 functions.

He presses the input and the LED#1 lights up, imediately, if he continues the switch input for a set amount of time, then LED#1 shuts off and LED#2 turns on,
so when the input is off, the LED#2 shuts off imediately..
 
what about an 8 pin pic to control it?
i've done something similar in the past:

Code:
RstBtnPress: 

PAUSE 70			' debounce

if portb.0 = 0 then		' if btn still down after debounce

			PAUSE 1000			' Wait 1000ms more			
				
				if portb.0 = 1 then		' if button has been let go in < 1000ms 
			
					gosub brightlcd          ' increase lcd backlight
					gosub LcdBothOn
					LCDOUT $FE,1				' clear both lcds
					gosub Lcd1on										
					LCDOUT $FE,$80,		"****************************************"			' Clear display and show that
					LCDOUT $FE,$C0,		"*          ALARM      DISABLED         *"			' Clear display and show that
					gosub Lcd2on
					LCDOUT $FE,$80,		"*                                      *"			' Clear display and show that
					LCDOUT $FE,$C0,		"****************************************"			' Clear display and show that
					alarmsilence = 1
				
				endif
			
			PAUSE 2000			' Wait 2000ms
			
							
				if portb.0 = 0 then			' if btn still down after another 2000ms (alarm on)
					
					gosub brightlcd        ' increase lcd backlight
					gosub LcdBothOn
					LCDOUT $FE,1				' clear both lcds
					gosub Lcd1on										
					LCDOUT $FE,$80,		"****************************************"			' Clear display and show that
					LCDOUT $FE,$C0,		"*          ALARM      ENABLED          *"			' Clear display and show that
					gosub Lcd2on
					LCDOUT $FE,$80,		"*                                      *"			' Clear display and show that
					LCDOUT $FE,$C0,		"****************************************"			' Clear display and show that
					alarmsilence = 0
				
				endif
	

endif
@ INT_RETURN 				' Return to main program
 
see the attached circuit using 4017 counter, when the push button is not pressed the counter remains on reset, when the switch is pressed it will give high to out-1 immediately within a second. then continue to hold the pus button pressed will make out-2 high after 4sec. hope this may be the one you need.
 

Attachments

  • press and hold out puts.JPG
    19.6 KB · Views: 159
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…