Interrupt Pin , Multiple Buttons, Diodes

Hello,

I am attempting(unsuccessfully) to get 2 buttons to fire interrupt pin(Int0, Pin2) on Arduino.
I have attached a basic example of what I am trying to do.
Fritzing Example

What is supposed to Happen: When the user presses any one of 2 buttons, the Arduino pin that is connected to the actual button fires as well as the interrupt. The code is interrupted. Arduino code looks at the 2 digital pins(pin7, pin8) to see which pin is high, and changes a value in the code that is relative to that button. (NOTE: This is an example, I am actually going to attach 8 buttons.)

What actually happens:
The interrupt works, but when Arduino looks to see which pin is high, both pins are high. It’s like the diodes are not working. At least the diodes are not working like I thought they would. Do diodes leak electrons in the opposite direction…?

Thanks,
CCL

Code Example Here:

#include "Tlc5940.h"
int pos = 0;
void setup()
{

  Tlc.init();

  pinMode(7, INPUT);
  pinMode(8, INPUT);
  attachInterrupt(0, changePos, RISING);
  
}




void loop()
{

  if (pos!=0){
    Tlc.clear();    
    Tlc.set(pos, 1000);   
    Tlc.update();
  }
delay(50);
     

}

void changePos() {
if (digitalRead(7)==HIGH){pos=1;}
if (digitalRead(8)==HIGH){pos=2;}

}

Took a very quick look at the code ...

  1. You're reading pin 18 instead of 8.
  2. Try to avoid using delay.

Thanks, I fixed it in the post. It was just a typo here. I double checked the arduino code in my actual sketch. Thanks. I will try getting rid of the delay.

I did something similar for my echopper. I went with hardware debouncing.

|500x398

Thank you very much. Nicely Done! I have found my problem. I will reply with fix in my next post.

My problem was how I placed my diodes. The diodes were doing nothing as I had soldered them incorrectly into a perma-proto board where they were along a common line. I took my Dremel and cut the line under the perma-proto board and it works.

Note: my hardware debouncing in the fritzing sketch will be removed (see png from orig post). I am not using it, and everything is working perfect.