Arduino sleep intterupt simple circuit

Hello Guyz

i have started using the Sleep tutorial example provided in the Arduino playground for a basic of my design.

This code works perfectly fine and i used a pushbutton switch to trigger the intterupt

Now i have altered the hardware part of this sketch from the pushputton switch to an op-amp and potentiometer, see attachment.

Also i have altered the the attachintterupt provided in the code to trigger on HIGH signal.

This does not seem to work, and i cannot figure out why.

I have tried to do the trigger step by step, first by potentiometer alone, this did succeed.

Could possibly be because the op amp require double supply so another -5V?

altho this other diagram also states that a one sided op amp would not require two power supplys

or could this possibly be another reason one of u experts might be familiar with?, like software problem?

arduino sleep comperator.jpg


Your comparator will always return true because you compare if the pot voltage is bigger than 0.
You have to put on the inverting input the voltage ref you compare to.
What do you exactly want to do?

In your arduino sleep hardware circuit, Vref is at ground so the comparator will fire with very little voltage at the Vin terminal. Add another pot connected as shown for Vin (or a fixed voltage divider) with the wiper connected to the Vref (-) input to set the level that Vin must reach to fire the comparator. Your AD820 opamp is specified as single supply capable.

Thank u guys for the quick reply ;D

i have noticed myself that the signal will only work when:

i have the trigger set up in LOW this could explain the following in the comments of the code:

"*/ In all but the IDLE sleep modes only LOW can be used."

and more bizare is that i have to switch the - and the + of the comperator, instead of using + as the input from the potmeter, i have to switch it with - and add the Vref/ground/0 to the + signal. (maybe aloyse-tech stated this, then i would like to know why, as since the diagram included says to add the Vref to - and not +.)

infact i want to notice the slightest voltage difference of like 1mV so thats why i have connected the comperator Vref pin to ground, anything other than 0 is desired to be used. The idea of this is to measure a tiny current of 1mA over a 300 Ohm resistor so that would be 300mV trigger which is almost zero.

So it works now only in the conditions mentioned above.