Okay, well here is the full code I have done at this point, much of it should be irrelevent
Main sketch:
//include required libraries
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <Stepper.h>
#include "LCD.h"
;
//===CONSTANTS and variables (buttons and pins)
const int buttonPin = 9; // start button
const int estopbutton = 8; //estop button
const int indexswitch = 7; //table index switch
const int indexmotor = 6; //table stepper motor
const int indexdir = 10; //table stepper direction pin
//===== LED PINS
const int stn1good = 50; //50
const int stn1bad = 52; //52
const int stn2good = 46; //46
const int stn2bad = 48; //48
//===== STEPPER PINS
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 42, 40, 38, 36);
int stepspeed = 10;
//ALSO SEE myStepper.setSpeed(100);
//==== LCD Variable
int LCDtest = 0;
int printtest;
void setup()
{
lcd.begin(20, 4); // SET LCD CONTRAST
lcdclear();
lcdbooting();
}
void loop()
{
printtest = 1;
LCDUPDATE::lcdupdate(printtest, 2, 3, 4, 5, 6, 7);
// TEST CYCLE
}
LCD.H
/*
LCD.h - Update QA machine LCD Display
*/
// ensure this library description is only included once
#ifndef LCD_h
#define LCD_h
// include types & constants of Wiring core API
#include <LiquidCrystal.h>
#include <Arduino.h>
// user-accessible "public" interface
class LCDUPDATE{
public:
void lcdupdate(int status1, int status2, int status3, int status4, int hstatus, int mstatus, int bstatus);
void lcdclear();
void lcdbooting();
private:
int status1old;
int status2old;
int status3old;
int status4old;
int hstatusold;
int mstatusold;
int bstatusold;
int test;
};
#endif
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//==== CLEAR THAT LCD
void lcdclear()
{
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print(" ");
}
void lcdbooting()
{
lcd.setCursor(0, 0);
lcd.print(" Booting! ");
lcd.setCursor(0, 1);
lcd.print("1:B 2:B 3:B 4:B");
}
//==== UPDATE LCD FUNCTION
void LCDUPDATE::lcdupdate(int status1, int status2, int status3, int status4, int hstatus, int mstatus, int bstatus)
{
// update
if (hstatus != hstatusold) {
if (hstatus == 1) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(" Boot Complete ");
}
if (hstatus == 2) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(" Ready For Start ");
}
if (hstatus == 3) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(" Indexing Table ");
}
if (hstatus == 4) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(" Process Stopped ");
}
if (hstatus == 5) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print(" Table Indexed ");
}
if (hstatus == 6) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print("Waiting for Stations");
}
if (hstatus == 7) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print("Stations Timeout!");
}
if (hstatus == 8) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print("QA Success Indexing");
}
if (hstatus == 9) {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 0);
lcd.print("Process Failure ");
}
hstatus = hstatusold;
}//END hstatus UPDATE
//== MSTATUS UPDATE
if (mstatus != mstatusold) {
if (mstatus == 1) {
lcd.setCursor(0, 2);
lcd.print(" ");
}
if (mstatus == 2) {
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("Ready for start");
}
if (mstatus == 3) {
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("Waiting for Stations");
}
if (mstatus == 4) {
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("Index Stage 1");
}
if (mstatus == 5) {
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("Index Stage 2");
}
if (mstatus == 6) {
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("Index Stage 3");
}
if (mstatus == 7) {
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print("Index Completed");
}
mstatusold = mstatus;
if (status1 != status1old) {
if (status1 == 1) {
lcd.setCursor(2, 1);
lcd.print("R");
status1 = status1old;
}
if (status1 == 2) {
lcd.setCursor(2, 1);
lcd.print("P");
status1 = status1old;
}
if (status1 == 3) {
lcd.setCursor(2, 1);
lcd.print("F");
status1 = status1old;
}
if (status1 == 4) {
lcd.setCursor(2, 1);
lcd.print("T");
status1 = status1old;
}
}
}//END STATUS1 UPDATE
if (status2 != status2old) {
if (status2 == 1) {
lcd.setCursor(6, 1);
lcd.print("R");
}
if (status2 == 2) {
lcd.setCursor(6, 1);
lcd.print("P");
}
if (status2 == 3) {
lcd.setCursor(6, 1);
lcd.print("F");
}
if (status2 == 4) {
lcd.setCursor(6, 1);
lcd.print("T");
}
status2 = status2old;
}//END status2 UPDATE
if (status3 != status3old) {
if (status3 == 1) {
lcd.setCursor(10, 1);
lcd.print("R");
}
if (status3 == 2) {
lcd.setCursor(10, 1);
lcd.print("P");
}
if (status3 == 3) {
lcd.setCursor(10, 1);
lcd.print("F");
}
if (status3 == 4) {
lcd.setCursor(10, 1);
lcd.print("T");
}
status3 = status3old;
}//END status3 UPDATE
if (status4 != status4old) {
if (status4 = 1) {
lcd.setCursor(14, 1);
lcd.print("R");
status4 = status4old;
}
if (status4 == 2) {
lcd.setCursor(14, 1);
lcd.print("P");
status4 = status4old;
}
if (status4 == 3) {
lcd.setCursor(14, 1);
lcd.print("F");
status4 = status4old;
}
if (status4 == 4) {
lcd.setCursor(14, 1);
lcd.print("T");
status4 = status4old;
}
}//END status4 UPDATE
if (bstatus != bstatusold) {
if (bstatus == 1) {
lcd.setCursor(0, 3);
lcd.print(" ");
}
if (bstatus == 2) {
lcd.setCursor(0, 3);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print("Moving Table CW");
}
if (bstatus == 3) {
lcd.setCursor(0, 3);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print("Moving Table CCW");
}
if (bstatus == 4) {
lcd.setCursor(0, 3);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print("Station Timeout: ");
}
bstatusold = bstatus;
}//END bstatus UPDATE
//====start stationtimer for bstatus == 4
// if (stationtimerstart != 0) {
// if (stationtimerstart == 2) {
// timer = stationtimer();
// if (timer != timerold) {
// lcd.setCursor(17, 3);
// lcd.print(timer);
// }
// }
// }
}