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;}
}