# external interupt from slight change in voltage

I have an attiny25 measuring a voltage value from a pot every 5 seconds. So basically the attiny sleeps and wakes up every 5 seconds to measure the voltage, if it hasn't changed it goes back to sleep. What I would like to know is, can my attiny perminantly sleep and only wakeup once the voltage value does change? That way I won't have to wakeup every 5 seconds to check it? I'm guessing en external interupt can only be a high or a low and analog values will not work? If that is true then is there no way I can use a comparator chip or something to create a high when the voltage changes?

The whole goal of this is to minimise battery power consumption. I need to get the attiny to flash a green LED every 5 seconds until movement of the pot is detected then it must flash a red LED. The problem is, once there is movement on the pot the red light must immediately flash, it must not wait 5 seconds before it flashes red.

One of us should really read the Atmega datasheet for the attiny25.

You first, I'm lazy

...R

can my attiny perminantly sleep and only wakeup once the voltage value does change?

If it can, this:

I need to get the attiny to flash a green LED every 5 seconds

isn't going to happen.

What is this voltage coming from? Why can't it power the attiny?

calvingloster:
The problem is, once there is movement on the pot the red light must immediately flash, ...

Define "immediately". Would 100 mS be close enough? 10 mS? 1 mS?

Yes 100ms would be fine. Not more than 300ms

PaulS:

can my attiny perminantly sleep and only wakeup once the voltage value does change?

If it can, this:

I need to get the attiny to flash a green LED every 5 seconds

isn't going to happen.

What is this voltage coming from? Why can't it power the attiny?

Ok I get what you are saying, the voltage is coming from a potentiometer.

3 AA batteries will be used to power the Attiny and the pot.

Well it seems to me the simple thing is to set up a watchdog timer to wake you every 250 mS, check the potentiometer and note any changes. Meanwhile every 20 times you wake (ie. 5 seconds) you can flash the LED.

See here for saving power and using the watchdog:

"Sketch I" on that page shows flashing an LED every second, so you could do something very similar to that.

I see what your saying, I will need the attiny to wake up to flash the LED every 5 seconds anyways. I was trying to figure out a way to flash the red LED "imediately" when a change in voltage occurs, but I'm guessing the attiny will have to wakeup every 250ms to measure this. Although battery power consumption will be increased greatly then. I will need the attiny to run on 3AA batteries for about 1year or as close to a year as possible. The longer the better

The LEDs are going to use a lot more power than the waking up. I have a gadget I made over a year ago that is still going strong:

That uses 3 x AA batteries.

That shows some other techniques, like sleeping during the ADC conversion.

My advice is to choose the batteries wisely. NiMh are notorious for fast self-discharge. Use non-rechargeable, or maybe Lithium ones.