Hi, I was wondering if it is possible to easily use a push-button to act as a TTL-compatible clock for an IC.
For example, I would like to use a counter that will go up by one each time I press a pushbutton. The problem I encountered when I tried to wire the push-button to the clock input of the counter directly is that due to the high rippling and 'roughness' of the push-button's contact, every time I pressed once, the counter would go up several bits.
Is there a relatively easy way (perhaps using a capacitor plus something else) to use a pushbutton or mechanical switch as a clock?
I want to do this because I don't want to use the cpu of the arduino to constantly monitor the switch and then send the signal to the counter.
Thanks lilpunk, smoothing is indeed what I envision to do.
I think I was a bit unclear though... what I want to do is to control the IC without the arduino.
I need some sort of hardware smoothing coupled with a compressor to convert the button's rippled signal to a clean square signal without the use of software. Some kind of hardware debounce.
I actually have 2 projects that would need this kind of stuff. One of them is reading a rotary encoder.
The other one involves a bike speedometer working off a magnetic switch - here my arduino won't be available for constant value polling, that's why I want to record the clicks on a counter.
If you can figure out the period of the bouncing, you can send the pushbutton output through a low-pass (RC) filter with a similar time constant, then use this filtered signal as your clock input.
You can use a simple circuit based on a 555 timer IC to debounce the switch. This gives you a very stable pulse out when you press the switch. The length of the pulse can be configured based on the components used.
Thanks guys!
Cool, as a matter of fact I have a 556 lie around somewhere under a pile of electronics :).
The RC looks even easier, even though I will have to check for the right resistor and capacitor values to use.