First off - Thanks in advance for the help. I have exhausted other resources, and it's time I ask for help.
Here is the scenario. I am building an automated system controlling external devices and receiving feedback signals throughout the process that I then use to control other things. The code, below, is a simple test code I am writing from the main program which I am using to test and troubleshoot to see if I can actually use an interrupt to watch signals in the background while other things are still happening in the main loop.
The variable "const int SE_RunningPin = 3" will be HIGH for about 8 minutes at a time. It is a signal being provided anytime an external process, which runs for 8 minutes, is active. Whenever that signal is active, I need to be monitoring the inputs "const int SE_LsaltPin = 8;" and "const int SE_PwrFltPin = 9;"
In my test code, I am just wiring up switches to toggle signals on and off, and then connect LED's to pins 12 and 13 to verify if "SE_Lsalt" and SE_PwrFlt" are being updated within the ISR.
So far, I am a bit stuck because the only avialable interrupt modes are LOW, CHANGE, RISING, FALLING. Since there isn't a HIGH mode, I thought, maybe I could put a while loop within the ISR to constantly read the SE_LsaltPin and SE_PwrFltPin while the SE_RunningPin is HIGH. In my tests, it reads it the first time, but then doesnt record any changes beyond that.
Does anyone have a different idea, or an idea on how to improve my code to meet my goals? I am testing on an UNO, but the main project will be on a MEGA 2560 R3.
Code:
const int SE_RunningPin = 3; //connected to switches for debugging
const int SE_LsaltPin = 8;
const int SE_PwrFltPin = 9;
const int SE_LsaltWarnPin = 12; //Connected to LED's for debugging
const int SE_PwrInterruptWarnPin = 13; //connected to LED's for debugging
volatile int SE_Lsalt = LOW; //variables to store value read off of pins 12 & 13
volatile int SE_PwrFlt = LOW;
void faultCheck() {
//do {
SE_Lsalt = digitalRead(SE_LsaltPin);
SE_PwrFlt = digitalRead(SE_PwrFltPin);
//} while (digitalRead(SE_RunningPin) == 1);
}
void setup() {
pinMode(SE_LsaltPin, INPUT);
pinMode(SE_PwrFltPin, INPUT);
pinMode(SE_LsaltWarnPin, OUTPUT);
pinMode(SE_PwrInterruptWarnPin, OUTPUT);
attachInterrupt(digitalPinToInterrupt(SE_RunningPin), faultCheck, LOW);
}
void loop() {
digitalWrite(SE_LsaltWarnPin, SE_Lsalt);
digitalWrite(SE_PwrInterruptWarnPin, SE_PwrFlt);
delay(5);
}