confusion with interrupts.

I have a code I'm using to calibrate when its pushed and held for more than 3 seconds which works great under normal conditions.
int reading = digitalRead(buttonPin);
if(reading != lastButtonState){
lastDebounceTime = millis();}
if((millis() - lastDebounceTime) > debounceDelay) {
if(reading != buttonState) { buttonState = reading;
if(buttonState == HIGH) {
ledState = !ledState;
}}
digitalWrite(LED, ledState);
lastButtonState = reading;}
while(digitalRead(buttonPin) == HIGH){
calibrate();

The above code works great until I added an interrupt for the rpm. The code for rpm by itself works great but somehow seems to be interfering. The serial monitor display s no data at all when the rpm is connected and voltage measured at the normally open end of the switch is high when it should be low. It doesn't make any sense to me. I have the RPM on interrupt 1. and the switch is on interrupt 3. (I'm using a mega)

rpm code is this simple...

if (millis() - lastmillis == 1000) {
detachInterrupt(1);
rpm = rpmcount*60;
rpmcount = millis();
attachInterrupt(1, rpm_fun, RISING);}

I tried calling the buttonPin as an INPUT as a INPUT_PULLUP and as an Interrupt all with the similar results. When its assigned as an INPUT it does display data but only for 5 seconds which is the debounceDelay I have set for the program to open the Bluetooth signal and send the saved data. confused? me too...

confused? me too...

Since you didn't post all of your code (or any of it correctly), I'll assume that the switch is on the interrupt pin that the "rpm" is connected to. If you want to prove that assumption incorrect, I imagine you'll think of something.

as it states above:

"I have the RPM on interrupt 1. and the switch is on interrupt 3. (I'm using a mega)"

"I have the RPM on interrupt 1. and the switch is on interrupt 3. (I'm using a mega)"

I really don't see how you can connect a "revolutions per minute" to interrupt pin anything. Now, really, what is connected to that pin?

I'd suggest that you ask the fine folks at http://snippets-r-us.com for help with your snippets.

Posting all the code is the first step to getting an answer as is clearly explained in several
places and sticky-threads.