// inputs
#define SYSTEM 3
#define CYCLE 6
// outputs
#define LIGHT 7
#define INTERLOCK 8
#define MCU 10
#define CLUTCH 11
#define STRIP_FEED 12
bool is_on = false;
int onoff=0; // used to test if power is on
int cyclepressed=0; //used to test if cycle buttonis pressed
void setup()
{
Serial.begin(9600);
pinMode(SYSTEM, INPUT); //Green PB
pinMode(CYCLE, INPUT); //Yellow PB
pinMode(LIGHT, OUTPUT); //Blue LED
pinMode(INTERLOCK, OUTPUT); //Green LED
pinMode(MCU, OUTPUT); //Orange LED
pinMode(CLUTCH, OUTPUT); //Light Blue LED
pinMode(STRIP_FEED, OUTPUT); //Violet LED
}
void loop()
{
// Check the state of both buttons at the start of each loop
onoff = digitalRead(SYSTEM);
cyclepressed = digitalRead(CYCLE);
Serial.print(onoff);
Serial.println(cyclepressed);
if (onoff == 1)
{
// Execute the startup sequence
digitalWrite(LIGHT, HIGH);
delay(500);
digitalWrite(INTERLOCK, HIGH);
digitalWrite( MCU, HIGH);
// set a flag
is_on = true;
}
else
{
// Excute shutdown sequence
digitalWrite(LIGHT, LOW);
delay(500);
digitalWrite(INTERLOCK, LOW);
digitalWrite( MCU, LOW);
// set a flag;
is_on = false;
}
// now test if the cycle pressed button is high.
if (cyclepressed == 1) //cycle start button pressed
{
if (is_on == true) // check that power is already on.
{
// put in code to carry out a cycle. i.e. engage clutch, move stripfeeder digitalWrite(CLUTCH, HIGH); // saw motor on
digitalWrite(CLUTCH, HIGH);
delay(500);
digitalWrite(CLUTCH, LOW);
delay(500);
digitalWrite(STRIP_FEED, HIGH);
delay(500);
digitalWrite(STRIP_FEED, LOW);
delay(500);
}
// reset the Cycle Button, applies to all cases.
digitalWrite(CYCLE, LOW);
} // End if cyclepressed
}// end of entire program. No code should appear beyond this point.