Broken Interrupt?

I wrote a sketch that uses both interrupts to handle a task and everything worked fine until suddenly the device got all buggy and responded as if one of the interrupts was being set off though it certainly was not. After hours of troubleshooting, I determined that Interrupt 0 (pin 2) was activating itself somehow. Using a multimeter, I detected a fluctuating voltage of about 0.1 volts between the pin and ground. The other interrupt pin showed a solid 0 volts.

Is anyone familiar with this problem or know how I may be able to remedy it? Thanks!

0.1 volts is not enough to trigger an interrupt. What do you have connected to these pins?

-- The Rugged Circuits Yellowjacket: 802.11 WiFi module with ATmega328P microcontroller, only 1.6" x 1.2", bootloader

I have a simple switch between the pin and 5V, then a 10k resistor between the pin and ground. It works just fine for the other one. Even when nothing is connected to the pin at all, the device responds as though it's being triggered. The routine following a trigger is very distinct so I'm certain that's what is happening. Additionally, if I remove all instances of that interrupt from the code, the behavior stops.

OK...the hardware sounds simple enough. Can we see the code?

-- Beat707: MIDI drum machine / sequencer / groove-box for Arduino

Have you tried cleaning the connections? Also sounds like something have worked loose and is not making good contact.

Thanks for the help. The code runs an electropneumatic revolving Nerf gun. A DC motor is used to turn a 15-barrel assembly. Interrupts are used for the trigger (properly functioning) and for the limit switch (broken) that tells the motor when it has indexed from one barrel to the next. The gun has semi and fully automatic modes, so the trigger’s interrupt has to be toggled even when the trigger is held down. The trigger interrupt gets its signal from a digital pin which is toggled within the code at the appropriate times. The interrupts are attached and detached and their flags reset at various points to provide debouncing. Hopefully this makes sense:

#include <avr/interrupt.h>

volatile int alignmentState = 0;    //Variable used to determine if barrels are aligned
int selectorState = 0;              //Variable used to store state of indexing switch

int motor = 12;                     //Motor control on pin 12
int valve = 11;                     //Valve control on pin 11
int fiveVline = 10;                 //fiveVline line for interrupt on pin 10
int selector = 9;                   //Selector switch input on pin 9

void setup(){
  //setting up trigger interrupt
  pinMode(3, INPUT);
  attachInterrupt(1, triggerISR, RISING);
  
  //setting up indexing interrupt
  pinMode(2, INPUT);
  attachInterrupt(0, indexingISR, RISING);
  
  //setting outputs
  pinMode(motor, OUTPUT);
  pinMode(valve, OUTPUT);
  pinMode(fiveVline, OUTPUT);
  
  //setting inputs
  pinMode(selector, INPUT);                             
  
  //setting start conditions
  digitalWrite(motor, LOW);                              //motor starts low
  digitalWrite(valve, LOW);                              //valve starts low
  digitalWrite(fiveVline, HIGH);                         //fiveVline line starts high
}

//Trigger ISR:
void triggerISR(){
  detachInterrupt(1);                                    //detach trigger switch
  digitalWrite(motor, HIGH);                             //turn motor
}

//Indexing ISR
void indexingISR(){
  detachInterrupt(0);                                     //detach indexing switch
  digitalWrite(motor, LOW);                              //stop motor
  alignmentState = 1;                                     //indicate barrel alignment
}

void loop(){
  //read and store state of indexing switch
  selectorState = digitalRead(selector);
  
  //Full Auto
  if((selectorState == 0) && (alignmentState == 1)){      //if selector is low and barrels are aligned
    digitalWrite(fiveVline, LOW);                         //cut fiveVline line for trigger interrupt
    delay(100);                                         
    digitalWrite(valve, HIGH);                            //valve open
    delay(10); 
    digitalWrite(valve, LOW);                             //valve closed
    delay(100);
    alignmentState = 0;                                   //reset alignment state
    EIFR |= 1<<INTF1;                                     //clear external interrupt 1
    EIFR |= 1<<INTF0;                                     //clear external interrupt 0
    attachInterrupt(1, triggerISR, RISING);               //reattach trigger
    attachInterrupt(0, indexingISR, RISING);              //reattach indexing
    digitalWrite(fiveVline, HIGH);                        //resume feed line for trigger interrupt
  }
   
   //Semi Auto 
   else if((selectorState == 1) && (alignmentState == 1)){    //if selector is high and barrels are aligned
    delay(100);
    digitalWrite(valve, HIGH);                              //valve open
    delay(10);
    digitalWrite(valve, LOW);                               //valve closed
    delay(100);
    alignmentState = 0;                                     //reset alignment state
    EIFR |= 1<<INTF1;                                       //clear external interrupt 1
    EIFR |= 1<<INTF0;                                       //clear external interrupt 0
    attachInterrupt(1, triggerISR, RISING);                 //reattach trigger
    attachInterrupt(0, indexingISR, RISING);                //reattach indexing
    selectorState = 0;
    }
  }