Storing short sensor inputs via capacitor

Hi, i have a few selfmade vibration sensors, which are basically just a hair trigger button. When the sensor vibrates a connection is made, otherwise they are disconnected. Since these are only connected for a very short time, i'm worried, that most of the time i will miss the connection while reading the value.

I was thinking of charging a capacitor via the sensor, then reading out the charge via an analog pin and discharging it via a digital one. But since i'm more of a software guy, all the circuits i can come up with seem needlessly complicated too me.

What would be the easiest / best way to sense wether a button was pressed and released while the arduino was sleeping? Preferrably with some indication wether it was a short or a long press.

Thanks, NsN

while the arduino was sleeping

Do you mean that? Why are you sending it into sleep mode?

Best way would be to use interrupts so that way an edge is not missed.

What would be the easiest / best way to sense wether a button was pressed and released while the arduino was sleeping

If the processor really is sleeping, then you could use an external interrupt to wake it.

If it isn't sleeping, then a tight loop will almost always catch your event. What may be "brief" to you in a mechanical sense may be a geological age to your processor.

I probably have a to academic approach to this. A tight loop just seems "unnatural" too me. In every topic that i've dealt with so far its just good practice to yield / sleep for as time much as possible. For this application it would be usefull too conserve power, but this isn't much of a concern. I was thinking of a loop taking measurements every 200 ms or so, sending out an update over the ethernetshield every 1-5 Minutes of the average and peak values.

I guess i could to a short check every 10-20ms, see if the vibration sensors and sound sensors have picked something up and measure light and temperature only every 20 loops. This will propably still give me a 1:10 active ratio.

I will try just meassuring it directly first, and then try out interrupts. Thanks!

NsN

[edit]good practice to yield / sleep for as time much as possible[/edit] Yield to what? The bit of your embedded app that isn't waiting for external events?

Yield to what? The bit of your embedded app that isn't waiting for external events?

Well for embedded applications it would be to conserve power. A tight loop would be a 100% load, if i only take as many measurements as i need, i could get this down to less than 1% on average. That has to make a difference, right?

That has to make a difference, right?

No it's an embedded processor. Unless you shut it down it keeps running the power is not affected by what it is doing. Any power saving are very small not worth bothering about.

Well for embedded applications it would be to conserve power. A tight loop would be a 100% load

Might be important on an ARM or more modern architecture, but this is an AVR, like Mike said, unless you put it to sleep, it isn't going to make a significant difference.