Button to trigger an interrupt

Hi, May be this question is so easy for you, but i prefer not to burn my duemilanove...

I checked the forum and internet, but i didn´t see anything clear.

I will use a RTC to trigger alarms to get up the arduino what will be sleeping. Not problem until this point. But, i would like to get up the arduino also by a button, just in case to need to do something when the arduino when it is not time ti get up by the alarm...

I tried this circuit for the button: http://www.arduino.cc/en/Tutorial/Button and it works perfect. But if i try to use it to trygger the alarm when the arduino is sleeping.. nothing happend.

I tested both code and circuit, and i have this conclusions:

The RTC alarm require the pin 2 in input and high modes, and the unique way to get up the arduino in that conditions is to use the button to get it up, is to wire one side of the button to digital pin 2, and the other (without resistances or any other element) to GND.

It seems to work perfectly, but i would like to have a confirmation that this way to wire the button and to use it in this case is not wrong. May be it ran for me during the five or six times that i tried, but it could burn the arduino for longer use...

So, am I in the right way by the use of this circuit and configuration? If not, could you give me some idea about what could i do to solve it? I can´t change the configuration of pin 2 because it is a requirement form RTC library, so i only can change the button' circuit.

Thanks so much!

The Arduino allows external interrupts on two pins - 2 and 3, I believe. If the RTC is using pin 2, then wire your switch to pin 3.

Thanks PaulS,

Yes, i know that, but i also use the pin 3 for a sensor that use interrupt... so my unique option is to use the digital pin 2... In fact i do not have any other pin to use...

But thanks for remember that!! Cheers

I think you want this - a Diode AND to create the interrupt. One side of the diodes connects to pin 2 (or 3) which is setup as an input with internal pullup enabled.

The other side of the diode goes to something that is normally +5V for example, or at least not connected to anything (like open contacts in a keypad). When the side goes Low (say to gnd) then the diode turns on and pulls pin 2 (or 3) low to create the interrupt. I use this to wake a remote control transmitter. Not even sure what the diodes are, just 4 of the same I had in a drawer.

Thanks CrossRoads,

Nice idea. for the moment i have the button connected to ground and the other side to INT0 (pin 2), and it seems to run.

So following your scheme, i understand that i must connect a diode in order to protect the arduino, wired in this way:

Digital pin 2 ----|>|-----[o]--------- GND Diode Button

Am i correct?


What RTC chip is it? Interrupt signals are normally open collector/drain so you can hook as many things onto the interrupt as you like.

If this is the case your switch just connects to GND and works in parallel with the RTC output.


Hi Graynomad,

I use a DS1337+. I use the INT0 for the alarms... and it works perfectly. Thanks!

The idea is that you connect your button thru one diode, and the other part thru a 2nd diode, thus either going low would trigger the interrupt of the arduino and still be electrically isolated. If your original part does not having its output dragged to ground by the button, then you can skip the diodes.

Thanks CrossRoads!!


Glad to help :-)