...And the other half:
int btnPin = 2; // Digital 2 ; 'Toggle' Button
int irPin = 3; // Digital 3 ; IR Detector
int bryPin = 5; // Digital 5 ; Bottom Right Yellow LED
int trgPin = 6; // Digital 6 ; Top Right Green LED
int blgPin = 7; // Digital 7 ; Bottom Left Green LED
int tlyPin = 8; // Digital 8 ; Top Left Yellow LED
int clockPin = 13; // Digital 9 ; SH_CP on Shift Register
int latchPin = 4; // Digital 10 ; ST_CP on Shift Register
int dataPin = 12; // Digital 11 ; DATA on Shift register
int blPin = 10; // Digital (PWM) 9 ; Red RGB LED
int cdsPin = 2; // Analog 2 ; CdS Cell
int rdPin = 9; // Digital (PWM) 10 ; Blue RGB LED
int gnPin = 11; // Digital (PWM) 11 ; Green RGB LED
int irval = 1;
int btnval = 1;
int cdsval = 0;
int pos = 0;
int i = 0;;
int b;
int mdl = false;
int prev = 0;
int time = 0;
void setup()
{
Serial.begin(9600);
time = 25; // How fast the pattern will go
pinMode(latchPin, OUTPUT);
pinMode(btnPin, INPUT);
//pinMode(irPin, INPUT);
pinMode(bryPin, OUTPUT);
pinMode(trgPin, OUTPUT);
pinMode(tlyPin, OUTPUT);
pinMode(blPin, OUTPUT);
pinMode(rdPin, OUTPUT);
pinMode(gnPin, OUTPUT);
clearLCD();
Serial.print(0xFE, BYTE);
Serial.print(0x0C, BYTE);
determineBacklight();
delay(100);
selectLineOne();
delay(100);
Serial.print("Main Menu");
delay(500);
for(i = 0; i < 10; i++) { // Fancy stuff
scrollLeft();
delay(100);
}
delay(1000);
}
void loop()
{
clearLCD();
pos = 130;
selectLineCustom();
Serial.print("Select Menu");
pos = 197;
selectLineCustom();
Serial.print("Option");
delay(700);
for(i = 0; i < 15; i++) { // More fancy stuff
scrollLeft();
delay(100);
}
clearLCD();
mainMenu();
}
void selectLineOne(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(128, BYTE); //position
}
void selectLineTwo(){ //puts the cursor at line 0 char 0.
Serial.print(0xFE, BYTE); //command flag
Serial.print(192, BYTE); //position
}
void selectLineCustom() {
Serial.print(0xFE, BYTE);
Serial.print(pos, BYTE);
pos = 0;
}
void scrollRight() {
Serial.print(0xFE, BYTE);
Serial.print(0x1C, BYTE);
}
void scrollLeft() {
Serial.print(0xFE, BYTE);
Serial.print(0x18, BYTE);
}
void clearLCD(){
Serial.print(0xFE, BYTE); //command flag
Serial.print(0x01, BYTE); //clear command.
}
void determineBacklight() {
cdsval = analogRead(cdsPin);
if(cdsval < 500) {
backlightOn();
}
else if(cdsval > 500) {
backlightOff();
}
}
void backlightOn(){ //turns on the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(157, BYTE); //light level.
}
void backlightOff(){ //turns off the backlight
Serial.print(0x7C, BYTE); //command flag for backlight stuff
Serial.print(128, BYTE); //light level for off.
}
void serCommand(){ //a general function to call the command flag for issuing all other commands
Serial.print(0xFE, BYTE);
}
void End() { // I use this for debugging
delay(500);
End();
}
void mainMenu() {
Serial.print("Press toggle to switch options");
delay(2000);
clearLCD();
Serial.print("Press select to select an option");
delay(2000);
clearLCD();
Serial.print("Light-Stopper");
option1();
}
void option1() { // This keeps the LCD at the menu option "Light Stopper
pinMode(irPin, INPUT); // until a button on the remote or 'toggle' is pressed
delay(100);
irval = digitalRead(irPin);
btnval = digitalRead(btnPin);
if(irval == 0 && btnval == 0) {
clearLCD();
Serial.print("??");
}
else if(irval == 0 && btnval == 1) {
clearLCD();
Serial.print("Light-Stopper");
lightStopper();
}
else if(irval == 1 && btnval == 0) {
clearLCD();
Serial.print("Simon");
option2();
}
else if(irval == 1 && btnval == 1) {
option1();
}
}
void option2() { // ...And this one keeps it at "Simon"
pinMode(irPin, INPUT); // menu option until a button is presses
delay(100);
irval = digitalRead(irPin);
btnval = digitalRead(btnPin);
if(irval == 0 && btnval == 0) {
Serial.print("??");
}
else if(irval == 0 && btnval == 1) {
clearLCD();
Serial.print("Simon");
Simon();
}
else if(irval == 1 && btnval == 0) {
clearLCD();
Serial.print("Light-Stopper");
option1();
}
else if(irval == 1 && btnval == 1) {
option2();
}
}
void Simon() { // (still haven't gotten to this yet...
Serial.print("Under Construction!");
delay(1000);
Simon();
}