Hey guys. I'm a having a problem with my project I have a pair of buttons connected to my inputs, using a 33uF capacitor to debounce the inputs. Using a multimeter I've determined that the hardware that I have created is functioning fine.
The issue I'm having is that the two interrupts appear to trigger each other. I've done extensive research and I can't find an issue. Could someone have a look at my code and see if this issue is coming from something else?
/*************************************************/
/**Dog Trial Timing software **/
/**Write by Hamish Bassett **/
/*************************************************/
/**All software written is believed to be */
/**origininal. If you believe that your software**/
/**has been copied unfairly contact the author **/
/**at deaths.swordsman@gmail.com **/
/*************************************************/
/**the purpose of this program is to take events**/
/**from the outside world and process them **/
/**as interupts, using the time to record the **/
/**events (dogs intersecting an external sensor)**/
/**and return the time that the dog was in the **/
/**course for the purpose of timing evnents **/
/**at dog club meets. It is then designed to **/
/** take the information on times collected and **/
/** send it back to a base station by use of a **/
/** third party Wi-Fi shield. **/
/*************************************************/
/** This software was written with the platform **/
/** of the Arduino Uno in mind, the details for **/
/** the platform can be found at the **/
/** manufacturers website URL is **/
/** http://www.arduino.cc/ **/
/*************************************************/
/** The software was written using the IDE for **/
/** the Arduino Uno found at **/
/** http://arduino.cc/en/Main/Software **/
/** all non standard C/C++ files are under the **/
/** GNU open source licence and are used as **/
/** distributed with the above IDE **/
/*************************************************/
//pin abstrations
const int interruptPinDigital2 = 0; //use an abstration to make the code easier to read
const int interruptPinDigital3 = 1; //an abstraction to make the code easier to read.
const int LEDPin = 13;
const int OutputLED1 = 8;
const int OutputLED2 = 9;
//all inputs must be volatile type as they can change independant of program.
volatile int state1= HIGH;
volatile int state2= HIGH;
volatile int Interrupt1_Flag=LOW;
volatile int Interrupt2_Flag=LOW;
#define TESTING 1 //TESTING is a variable that =1 if the project is testing using a development board (in house only)
void setup () //the inbuilt function to set up the output values of the pins.
{
//pin configurations; Unnamed pins are unused and declared in preparation for internal pull up resistor to be turned on
pinMode (0, INPUT); pinMode (1, INPUT);
pinMode (4, INPUT); pinMode (5, INPUT);
pinMode (6, OUTPUT); pinMode (7, INPUT);
pinMode (OutputLED1, OUTPUT); pinMode (OutputLED2, OUTPUT);
pinMode (10, INPUT); pinMode (11, INPUT);
pinMode(12, INPUT);
pinMode (LEDPin, OUTPUT); //make pin 13 as an output pin
//pin high settings turn on internal pull up resistors for unused pins
digitalWrite (0, HIGH); digitalWrite (1, HIGH);
/*digitalWrite (3, HIGH);*/ digitalWrite (4, HIGH);
digitalWrite (5, HIGH); digitalWrite (6, HIGH);
digitalWrite (7, HIGH); digitalWrite (8, HIGH);
digitalWrite (9, HIGH); digitalWrite (10, HIGH);
digitalWrite (11, HIGH); digitalWrite(12, HIGH);
//pin interrupt associations
attachInterrupt( interruptPinDigital2, DataRetrieval1, RISING); //associate funtion DataRetrieval with Pin 2 changing state.
attachInterrupt( interruptPinDigital3, DataRetrieval2, RISING); //associate funtion DataRetrieval2 with Pin 3 changing on the rising edge
// Interrupt(); //Ensure interrupt on ************************ Causes an Error
Serial.begin(9600);
Serial.println("Dog Trial Starter");
}
//Arduino equivalent to main.
void loop ()
{
#if TESTING
digitalWrite(OutputLED1, state1);
digitalWrite(OutputLED2, state2);
if (Interrupt1_Flag)
{
Serial.println("Interrupt 1 Flag tripped");
Serial.println("");
Interrupt1_Flag=LOW;
}
if (Interrupt1_Flag)
{
Serial.println("Interrupt 2 Flag tripped");
Interrupt2_Flag=LOW;
}
#endif
#if !TESTING
#endif
}
//prototype
#if TESTING
void DataRetrieval1 ()
{
//Serial.println("DataRetrieval1");
//state1=!state1;
state1 = HIGH;
state2 = LOW;
Interrupt1_Flag=HIGH;
}
void DataRetrieval2 ()
{
//Serial.println("DataRetrieval2");
//state2=!state2;
state1 = LOW;
state2 = HIGH;
Interrupt2_Flag=HIGH;
}
#endif
#if !TESTING
void Sensor ( /*inputs, I have no idea atm*/)
{
//The progam must modify a global counter and test to see if it is the correct value.
//If it's the incorrect value send a fault through the wifi
//if not then send the time to the wifi unit
//then change the value of the global counter
}
#endif