For what it's worth... part 1
#include <SoftwareSerial.h>
#define rxPin 4 // SoftwareSerial RX digital PIN 4
#define txPin 3 // SoftwareSerial TX digial PIN 3
#define LCD_RS 12 // Register select
#define LCD_EN 6 // Enable
#define LCD_D4 7 // Data bits
#define LCD_D5 8 // Data bits
#define LCD_D6 9 // Data bits
#define LCD_D7 10 // Data bits
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin); // declaring SoftwareSerial 'mySerial' and pins used
int ledPin = 13; // LED on DIGITAL PIN 13
unsigned long lastActivity; // used to store time of each button press, so a script can time-out after an interval
long timeout = 10000; // stores the interval in milliseconds when unit should time-out and go to welcome/status screen
long timeoutScreen = 1;
char clearBuffer[] = "0x0A"; // Sanyo projector clear buffer command.
byte execute = 0x0D; // Sanyo projector execute command. To be sent after every instruction
char proj_powerON[] = "C00"; // Turn Projector On
char proj_powerOFF[] = "C01"; // compuslorty Power OFF
char proj_inputPC[] = "C05"; // set to computer 1 input
char proj_inputDVD[] = "C06"; // set to video input
char proj_autoAdjust[] = "C89"; // auto pc adjust
char proj_statusPower[] = "CR0"; // Check status of power
char proj_statusInput[] = "CR1"; // Check status of input
char proj_lampHours[] = "CR3"; // Check lamp hours
int menuUp = 0; // menu rocker UP is ANALOG PIN 0
int menuDn = 1; // menu rocker DOWN is ANALOG PIN 1
int menuSel = 2; // menu SELECT button is ANALOG PIN 2
int powerSel = 3; // power select switch is ANALOG PIN 3
int inputPC = 11; // PC input is DIGITAL PIN 11
int inputDVD = 5; // DVD input is DIGITAL PIN 5
int hiThreshold = 1023; // threshold for HIGH analog inputs
int lowThreshold = 5; // threshold for LOW analog inputs
int hiReset = 900; // reset button status when value falls below hiReset - prevents accidental repeat of button input
int lowReset = 200; // same but for low...
int menuUpReset = 0; // has button status been reset? 1 yes, 0 no - don't change this value
int menuDnReset = 0; // has button status been reset? 1 yes, 0 no - don't change this value
int menuSelReset = 0; // has button status been reset? 1 yes, 0 no - don't change this value
int powerSelReset = 0; // has button status been reset? 1 yes, 0 no - don't change this value
int inputPCReset = 0; // has button status been reset? 1 yes, 0 no - don't change this value
int inputDVDReset = 0; // has button status been reset? 1 yes, 0 no - don't change this value
int statusUp = 0; // holds temp status of menuUp button
int statusDn = 0; // holds temp status of menuDn button
int statusSel = 0; // holds temp status of menuSel button
int statusPw = 0; //holds temp status of powerSel switch
int statusPC = 0; //holds temp status of PC select switch
int statusDVD = 0; //holds temp status of DVD select switch
int menu_current = 0; // default menu location
int menu_first = 1; // first menu location
int menu_last = 4; // last menu location
int menu_under = 0; // 'you've gone to far back, move to end'
int menu_over = 5; // 'you've gone to far over, move to beginning'
int menu_option = 0; // stores where the program should go when the SEL button is pressed
int power_STATUS = 2; // holds power status value. 0 > OFF, 1 > ON
int input_STATUS = 2; // holds input status value. 0 > PC, 1 > DVD
int startup = 1; // during first execution of loop, if startup = 1 will fire welcome screen for 5 seconds
char incomingPower[2] = {0,0}; // placeholder for incoming serial communication from projector - projector status
byte incomingInput = 0; // placeholder for incoming serial communication from projector - which input
char incomingLamp[4] = {9,9,9,9}; // placeholder for incoming serial communication from projector - lamp run time
char incomingTemp[6] = {0,0,0,0,0,0}; // placeholder for incoming serial communication from projector - temp
char statusString[2]; // temporary holding of current projector status
char tempString[4]; // temporary holding of current projector temp
char lampString[4]; // temporary holding of current lamp hours
void lcd_strobe()
{
digitalWrite(LCD_EN,HIGH);
digitalWrite(LCD_EN,LOW);
}
/* write a byte to the LCD in 4 bit mode */
void lcd_write(byte c)
{
if(c & 0x80) digitalWrite(LCD_D7,HIGH); else digitalWrite(LCD_D7,LOW);
if(c & 0x40) digitalWrite(LCD_D6,HIGH); else digitalWrite(LCD_D6,LOW);
if(c & 0x20) digitalWrite(LCD_D5,HIGH); else digitalWrite(LCD_D5,LOW);
if(c & 0x10) digitalWrite(LCD_D4,HIGH); else digitalWrite(LCD_D4,LOW);
lcd_strobe();
if(c & 0x08) digitalWrite(LCD_D7,HIGH); else digitalWrite(LCD_D7,LOW);
if(c & 0x04) digitalWrite(LCD_D6,HIGH); else digitalWrite(LCD_D6,LOW);
if(c & 0x02) digitalWrite(LCD_D5,HIGH); else digitalWrite(LCD_D5,LOW);
if(c & 0x01) digitalWrite(LCD_D4,HIGH); else digitalWrite(LCD_D4,LOW);
lcd_strobe();
delayMicroseconds(40);
}
/*
* Clear and home the LCD
*/
void
lcd_clear(void)
{
digitalWrite(LCD_RS,LOW);
lcd_write(0x1);
delay(2);
}
/* write a string of chars to the LCD */
void
lcd_puts(const char * s)
{
digitalWrite(LCD_RS,HIGH); // write characters
while(*s) lcd_write(*s++);
}