Question about using buttons and interrupts

Post content partially lost due to vandalism by author

I have 2 push buttons. 1 is connected to pin 2 ( INT0 ) and pulled down, pressing it connects it to 5v via resistor.
The other push button to pin 3 ( INT1 ) and pulled up, pressing it connects it to ground via resistor.

Ardunaut:
I have 2 push buttons. 1 is connected to pin 2 ( INT0 ) and pulled down, pressing it connects it to 5v via resistor.
The other push button to pin 3 ( INT1 ) and pulled up, pressing it connects it to ground via resistor.

Your circuit description sounds suspicious. The via resistor part. The pin should go to a junction of the resistor and switch. The other side of the switch goes to 5v or ground, depending on pull up or down. Is that how you have it?

If you hadn't indicated the way you wired things I would have said use a pull down with switching to VCC.

I don't understand why you detach the interrupts. Don't you need them for your scheme to work ?

Please use code tags.

Read this before posting a programming question

How to use this forum

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the "Code" icon above the posting area. It is the first icon, with the symbol: </>

You may need to clear an outstanding interrupt flag.

If i understand correctly i need to put this in my code ? like at the end of the loop ?

EIFR = 1;

EIFR = 2;

Before you attach the interrrupt, yes. Better is to use the version a few lines down that make it clearer what you are doing:

EIFR = bit (INTF0);  // clear flag for interrupt 0
EIFR = bit (INTF1);  // clear flag for interrupt 1

Doesnt the attach / detach function has something like this build in ?

No.

Glad it worked. The reference page for AttachInterrupt does mention my page. So whilst it might not directly be on the page you at least have a chance of finding it.

Ardunaut:
I attached a picture of my wiring. But like u stated, it seems wrong what i did.
I now removed the other resistors and only left the pull up/down ones, this should be right ?

Yes.