Interrupt counting

Hi All,

Im trying to count using an interrupt.

I have an ISR which adds a number to a parameter each time a button is pressed.

The problem is when I press the button the interrupts makes allot of loops and the count goes very high instead of increasing by 1 unit for every press.

The button is normally close and HIGH so when I push the button the input goes to LOW .Ive tried starting the interrupt only when the inpout is RISING but it didnt work....

Here is the interrupt code:

"
void Greenbutton() {

buttonState=buttonState+1;
Serial.begin(9600);
Serial.print(buttonState);

}"

I should also add that the serial monitor sometimes shows gybrish instead of the value of the parameter...

Thanks,
Ron.

Here is the interrupt code:

Where is the rest of the code, and the schematic?

Don't print or otherwise muck about with serial in an interrupt.

You cannot use Serial.print() in an ISR because it uses interrupts and they are automatically disabled

You only need to use Serial.begin() once in setup(), not in the ISR

You have not posted a complete program but buttonState should be declared volatile as it is changed in the ISR

You have not said what type of trigger you are using for the ISR

As we can't see your code we don't know if the input is debounced

Advice :
read this before posting a programming question then post your complete program following the advice given in that link

Maybe you should up what the term parameter means.

Interrupt routines have no parameters.