No interruptions

I have 4 tactile switches on pins 5 through 8, with 15k pullups to 5V, I have ORed the 4 switches to Pin 2 with anoded to pin 2 , cathodes to the tactile switches also with a 15k pullup on pin 2. I am using the following code but never see a falling edge event on any of the switches. I have also use interrupt option LOW with the same effect. The oscilloscope shows proper lefel state changes at the Arduino’s input headers. The sinewave function is manipulating the class correctly. I have tried Serial.println commands withing the ISR and never see any output.

#include "ExternPWM.h"
ExternPWM LeftWing;
void setup()
  {
    LeftWing.Stages(CD4020B);
    LeftWing.IncrementPin(3);
    LeftWing.DecrementPin(4);
    LeftWing.PWMRatio(50);
    LeftWing.Invoke();
    //Serial.begin(9600);
   pinMode(2,INPUT);
   pinMode(5,INPUT);
   pinMode(6,INPUT);
   pinMode(7,INPUT);
   pinMode(8,INPUT);
   attachInterrupt(2,KeyRead,FALLING);
  }
void FastDown()
  {
    LeftWing.Decrement(200);
    //Serial.println("Fast Down");
    return;
  }
void SlowDown()
  {
    LeftWing.Decrement(1);
    //Serial.println("Slow Down");
    return;
  }
void FastUp()
  {
    LeftWing.Increment(200);
    //Serial.println("Fast Up");
    return;
  }
void SlowUp()
  {
    LeftWing.Increment(1);
    //Serial.println("Slow Up");
    return;
  }
void KeyRead()
  {
    //Serial.println("ISR Entered");
    if (digitalRead(8) == LOW)
      {
        FastDown();
      }
    else if (digitalRead(7) == LOW)
      {
        SlowDown();
      }
    else if (digitalRead(6) == LOW)
      {
        SlowUp();
      }
    else if (digitalRead(5) == LOW)
      {
        FastUp();
      }
  }
void loop()
  {
    unsigned long i;
    float passVal;
    float angle;
    //Serial.println(LeftWing.Stages());
    for (i=0;i<6280;i++)
       {
        //digitalWrite(3,1);
        //digitalWrite(3,0);
        angle = (float)i/1000;
        passVal = 1 + sin(angle);
        passVal = passVal * 40;
        LeftWing.PWMRatio(passVal);
        //Serial.println(i);
        delay(25);
        //Serial.println(i);
      }
  }

cmos.h (169 Bytes)

ExternPWM.cpp (3.17 KB)

ExternPWM.h (645 Bytes)

It helps if you post proper code, you know stuff that actually will compile.

Sorry is used the “copy for forum”, reposting…

 attachInterrupt(2,KeyRead,FALLING

Is not the interrupt that uses pin 2. Check the referance.

The hardware section of the site said my Arduino Uno v3 uses pins 2 and 3 for external interrupts.

INT0 = pin 2, INT1= pin 3! The documentation is vague, I went to the port pin mapping diagram. INT0 is working

Have you got it now?
attachInterrupt(0,KeyRead,FALLING);

Yes, I have noted one quirk though. If LOW is used, I never exit the ISR. I know this by the virtue that the free run sine generator stops after a keypress. FALLING, RISING, and CHANGE all read the keypresses and return to the loop() afterward. I see that I will need to add a while pressed loop to each button press condition so that continued presses continue to accumulate adjusments. 4096 is alot of individual keypresses. I saw that the reference page for attachInterrupt() gave the correct interrupt to pin reference, but the board hardware page alluded to pin = interrupt number.

If LOW is used, I never exit the ISR.

Are you sure about that? When LOW is used, the ISR is called over and over, until the pin is not LOW.

Yes all inputs high, yet no return to loop(). Interupt types other than low behaving as expected.