Help with Interrupts

Hi all,

I have this code (courtesy of larryd) which will monitor the input pins 2,4,6 and if it sees the input, it'll turn on the output pin 8,10,12 respectively.. As of now it'll make sure only one output is on at a time and it'll WAIT on the current input pin to turn LOW before it monitors the next input and turns on the respective output. Now there is a small change and I want to make sure it doesn't wait for the current input to turn low before it switches, instead e.g if input pin 2 is high and input pin 4 gets the signal, output pin 10 should immediately turn high after making output pin 8 low. How can I edit the current code to do that. Thanks


// code courtesy larryd

#define materialNeeded LOW
#define disable true
#define enable false
#define solenoidON HIGH
#define solenoidOFF LOW

const byte Press1 = 2;
const byte Press2 = 4;
const byte Press3 = 6;

const byte Lim1 = 8;
const byte Lim2 = 10;
const byte Lim3 = 12;

const byte heartBeatLED = 13;

byte lastPress1;
byte lastPress2;
byte lastPress3;

bool checkPress1 = enable;
bool checkPress2 = enable;
bool checkPress3 = enable;

//timing stuff
unsigned long switchMillis;
unsigned long heartBeatMillis;

//********************************************************************
void setup()
{
pinMode(Press1, INPUT_PULLUP);
pinMode(Press2, INPUT_PULLUP);
pinMode(Press3, INPUT_PULLUP);

pinMode(Lim1, OUTPUT);
pinMode(Lim2, OUTPUT);
pinMode(Lim3, OUTPUT);

pinMode(heartBeatLED, OUTPUT);

} //END of setup()

//********************************************************************
void loop()
{
//************************
//toggle the Heart Beat LED every 500ms to show the sketch is running
if (millis() - heartBeatMillis >= 500)
{
//restart timer
heartBeatMillis = millis();

//toggle Heart Beat LED
digitalWrite(heartBeatLED, !digitalRead(heartBeatLED));
}

//************************
//time to check the switches?
if (millis() - switchMillis >= 50)
{
//restart timer
switchMillis = millis();

checkSwitches();
}

//************************

} //END of loop()

//********************************************************************
void checkSwitches()
{
byte switchState = 0;

//************************
//Press1 Switch
switchState = digitalRead(Press1);

if (checkPress1 == enable && lastPress1 != switchState)
{
//update to the new state
lastPress1 = switchState;

if (switchState == materialNeeded)
{
digitalWrite(Lim1, solenoidON);

checkPress2 = disable;
checkPress3 = disable;
}

else
{
digitalWrite(Lim1, solenoidOFF);

checkPress2 = enable;
checkPress3 = enable;
}
}

//************************
//Press2 Switch
switchState = digitalRead(Press2);

if (checkPress2 == enable && lastPress2 != switchState)
{
//update to the new state
lastPress2 = switchState;

if (switchState == materialNeeded)
{
digitalWrite(Lim2, solenoidON);

checkPress1 = disable;
checkPress3 = disable;
}

else
{
digitalWrite(Lim2, solenoidOFF);

checkPress1 = enable;
checkPress3 = enable;
}
}

//************************
//Press3 Switch
switchState = digitalRead(Press3);

if (checkPress3 == enable && lastPress3 != switchState)
{
//update to the new state
lastPress3 = switchState;

if (switchState == materialNeeded)
{
digitalWrite(Lim3, solenoidON);

checkPress1 = disable;
checkPress2 = disable;
}

else
{
digitalWrite(Lim3, solenoidOFF);

checkPress1 = enable;
checkPress2 = enable;
}
}
//************************

} //END of checkSwitches

//********************************************************************

Please update your post using code tags

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

Your code is too long for me to study quickly without copying to my text editor.

From a cursory look at your program I see no sign of any interrupts.

...R