Go Down

Topic: Buttons, interrupts and de-bouncing (Read 2 times) previous topic - next topic


I have two Mega but they also have just 6 interrupt pins.

No, you can have an interrupt for any pin just as tuxduino describes.

There is a library for it. Read this thread - http://arduino.cc/forum/index.php?topic=87195.0 -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


I will read i later. But just from overflying it i thought its just for the ATmega328p.

So does it make sense to always use interrupts for switching state instead of using
just digital IN and look at it all the time in a loop?
Please correct me if my logical thinking is not right :|


Polling is perfectly usable to manage buttons, provided you read the pin status at least once in 20 to 50 ms. That means banning delay() and switching to state-based programming.


I think the real problem is using interrupts to detect button presses.

It sounds neat/cool/whatever but it's not really a good idea in practice...
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)


Cool? Hm, i think nobody ever will ask: "hey how does this button work? do you use interrupts?"
If i build a egg timer for my 60 years old Mother. She never ever will look at the code or ask.
An Arduino for a egg timer *looool
But who knows. When Skynet comes alive and all machines communicate, maybe the egg timer is
in charge for the timing of the Terminator sorties :D

I just want to figure out whats the right way to do it. If you need to check the inputs
in the loops then the Atmega uses energy you maybe need for other stuff.
I always think that stuff needs to be build that it uses the least energy.
The other thing i read at Jeremy's (Blum) blog is:
Interrupts allow you run a program, while still being able to react to asynchronous input from the outside world.

So you can do stuff at the same time.

Go Up