Hello, I am making this project to expand on a school project, and I was having some problems with it switching modes. I want it to be able to switch modes between a data bank for different things, and the other is a small game box. I have removed some code to simplify it, so apologies if you see any integers or Booleans you cant find. this code does compile on my computer, and my error is that when I try to get it to switch modes, i am using EEPROM, it does not seem to read it in this sketch for some reason. it does show the EEPROM value at 4, the address I am using as 1, as it should, but the program does not work. Thank you for any help.
int versions;
bool bank = false;
int banks;
// Data Bank Code
const char* User1 = "DroneMaster278";
const char* User1pass = "31.5x2=Awesome!";
unsigned long lockstart = 0;
unsigned long lockoutend;
String lastcommand;
char CurrentUser;
int value1;
int left = 3;
int tries = 3;
int minute = 0;
int fails;
int t;
bool Lockdown;
bool lock2 = false;
bool ask = true;
void (*resetFunc)(void) = 0;
bool serialconnected = false;
void Version() {
if (serialconnected == true) {
Serial.print("Version ");
Serial.print(1.);
Serial.println(versions);
}
}
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <EEPROM.h>
/*
EEPROM Key
100 = Game 1 High Score
101 = Game 2 High Score
102 = Game 3 High Score
104 = Lockdown 1=on 2=off.
103 = Refresh Rate
105 = Game 1 Seconds
106 = Game 2 Seconds
107 = Game 3 Seconds
108 = Game 1 Minutes
109 = Game 2 Minutes
110 = Game 3 Minutes
111 = Sound 1 = On 2 = Off
112 = Lights 1 = On 2 = Off
113 = Version
114 = developer mode 1=on 2=off
115 = sensitivity
*/
int EEPROMLIGHTS = 112;
int EEPROMSOUND = 111;
int minutes1 = 2;
int seconds1 = 59;
int minutes2 = 2;
int seconds2 = 59;
int minutes3 = 2;
int seconds3 = 59;
int rrate = 5;
int refreshrate = 300;
int EEPROMG1HS = 100;
int EEPROMG2HS = 101;
int EEPROMG3HS = 102;
int EEPROMLockdown = 104;
int EEPROMRR = 103;
int EEPROMG1S = 105;
int EEPROMG2S = 106;
int EEPROMG3S = 107;
int EEPROMG1M = 108;
int EEPROMG2M = 109;
int EEPROMG3M = 110;
int done = 0;
int finished = 0;
int steps = 16;
int g3highscore = 0;
int g2highscore = 0;
int g1highscore = 0;
int launchint5;
int launchint51;
int launchint52;
int int0;
int triesleft = 2;
// Custom Characters
byte customChar[8] = {
0b00000,
0b00000,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
};
// libraries
#define resetpin A1
#define greenbutton A15
#define redbutton A14
#define yellowbutton A13
#define joy1B A12
#define joy1X A11
#define joy1Y A10
#define joy2B A9
#define joy2X A8
#define joy2Y A7
#define flicker 11
#define rotaryB 10
#define rotarybutton 10
#define rotary2 9
#define encoderPinA 9
#define rotary1 8
#define encoderPinB 8
#define buzzer 6
#define touch2 5
#define touch1 4
#define touch3 3
#define led1 53
#define led2 51
#define led3 49
#define led4 47
#define led5 45
#define led6 43
#define led7 41
#define led8 39
#define led9 37
#define led10 35
#define greenB A15
#define yellowB A13
#define redB A14
String command;
String lastCommand;
int game1hs;
int int10;
int int11;
int int12;
int int13;
int int14;
int sense;
bool nosound;
bool Light = false;
bool developermode = false;
// sensor states
int joy2Bs;
int touch1s;
int touch2s;
int touch3s;
int joy1Bs;
int twisters;
int greenBs;
int yellowBs;
int redBs;
int rotaryBs;
int flickers;
int joy1Xs;
int joy1Ys;
int joy2Xs;
int joy2Ys;
int rotary1s;
int rotary2s;
int greenbs;
int yellowbs;
int redbs;
int joy1bs;
int joy2bs;
const char* game1words[24] = { " Touch It", " Twist It", " Click It", "Pres the Joystick", " Flick It",
"Pres the Joystick", " Touch It", " Twist It", "Pres the Joystick", " Flick It",
" Click It", " Flick It", "Pres the Joystick", " Touch It",
"Pres the Joystick", " Flick It", " Click It", " Touch It",
" Flick It", " Click It", " Twist It", " Click It", " Flick It",
" Twist It" };
const char* GameSettings[5] = { "High Scores"
" Time"
" Sounds"
" Lights"
" Rules" };
int rlights[30]{
led8, led2, led4, led6, led7, led8, led5, led3, led1, led2, led1, led10, led9, led4, led10,
led4, led3, led2, led10, led9, led6, led7, led6, led3, led9, led7, led8, led5, led1, led5
};
int current1[125]{ 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 17,
16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8,
7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2,
1, 0, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17 };
int current2[125]{ 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 17, 16, 15,
14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17 };
int current3[125]{ 17, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 17, 17, 16, 15, 14,
13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 16,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 };
void timereset() {
seconds1 = EEPROM.read(EEPROMG1S);
seconds2 = EEPROM.read(EEPROMG2S);
seconds3 = EEPROM.read(EEPROMG3S);
minutes1 = EEPROM.read(EEPROMG1M);
minutes2 = EEPROM.read(EEPROMG2M);
minutes3 = EEPROM.read(EEPROMG3M);
}
void sentcommands() {
Serial.print("Received: ");
Serial.println(command);
}
volatile int encoderPosition = 0;
volatile bool encoderTwisted = false;
void percentagefinished() {
done = done + 1;
lcd.clear();
finished = 100 / steps * done;
if (developermode == true) {
lcd.print(finished);
lcd.print("%");
if (serialconnected == true) {
Serial.print(finished);
Serial.println("%");
}
}
delay(random(100, 300));
if (finished > 10) {
lcd.backlight();
digitalWrite(led1, HIGH);
}
if (finished > 20) {
digitalWrite(led2, HIGH);
}
if (finished > 30) {
digitalWrite(led3, HIGH);
}
if (finished > 40) {
digitalWrite(led4, HIGH);
}
if (finished > 50) {
digitalWrite(led5, HIGH);
}
if (finished > 60) {
digitalWrite(led6, HIGH);
}
if (finished > 70) {
digitalWrite(led7, HIGH);
}
if (finished > 80) {
digitalWrite(led8, HIGH);
}
if (finished > 87) {
digitalWrite(led9, HIGH);
}
if (finished > 95) {
digitalWrite(led10, HIGH);
}
}
void setup() {
banks = EEPROM.read(4);
delay(50);
if (banks == 1) {
Serial.begin(115200);
Serial.println("Data Bank Mode Entered");
bank = false;
Serial.println("hi");
} else if (bank == false) {
banks = true;
Serial.println("bye");
}
if (bank == false) {
lcd.clear();
pinMode(touch1, INPUT_PULLUP);
pinMode(touch2, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
pinMode(joy1X, INPUT);
pinMode(joy1Y, INPUT);
pinMode(joy2X, INPUT);
pinMode(rotaryB, INPUT_PULLUP);
pinMode(resetpin, OUTPUT);
pinMode(joy2Y, INPUT);
pinMode(rotary1, INPUT_PULLUP);
pinMode(flicker, INPUT);
pinMode(rotarybutton, INPUT_PULLUP);
pinMode(rotary2, INPUT_PULLUP);
pinMode(joy1B, INPUT_PULLUP);
pinMode(joy2B, INPUT_PULLUP);
pinMode(greenbutton, INPUT_PULLUP);
pinMode(redbutton, INPUT_PULLUP);
pinMode(yellowbutton, INPUT_PULLUP);
pinMode(touch3, INPUT_PULLUP);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(led9, OUTPUT);
pinMode(led10, OUTPUT);
pinMode(greenB, INPUT_PULLUP);
pinMode(redB, INPUT_PULLUP);
pinMode(yellowB, INPUT_PULLUP);
percentagefinished();
int13 = EEPROM.read(114);
}
if (bank == true) {
value1 = EEPROM.read(1);
left = EEPROM.read(2);
fails = EEPROM.read(3);
}
if (bank == false) {
lcd.begin(16, 2);
lcd.clear();
if (int13 == 1) {
developermode = true;
} else developermode = false;
int14 = EEPROM.read(115);
sense = int14;
digitalWrite(resetpin, HIGH);
lcd.createChar(0, customChar);
int12 = EEPROM.read(113);
versions = int12 + 1;
percentagefinished();
attachInterrupt(digitalPinToInterrupt(encoderPinA), handleEncoderInterrupt, CHANGE);
EEPROM.update(113, versions);
lcd.init();
percentagefinished();
Serial.begin(115200);
if (serialconnected == true) {
Serial.println("Booting Up");
}
percentagefinished();
int10 = EEPROM.read(111);
percentagefinished();
if (int10 == 1) {
nosound = true;
} else nosound = false;
percentagefinished();
int11 = EEPROM.read(112);
percentagefinished();
if (int11 == 2) {
Light = false;
} else Light = true;
percentagefinished();
//Serial.println("bool4 question");
// pinmodes
percentagefinished();
// senor state readers
touch1s = digitalRead(touch1);
touch2s = digitalRead(touch2);
touch3s = digitalRead(touch3);
joy1Bs = digitalRead(joy1B);
joy2Bs = digitalRead(joy2B);
greenBs = digitalRead(greenB);
rotaryBs = digitalRead(rotaryB);
redBs = digitalRead(redB);
yellowBs = digitalRead(yellowB);
rotaryBs = digitalRead(rotarybutton);
joy2Xs = analogRead(joy2X);
joy2Bs = digitalRead(joy2B);
joy2Ys = analogRead(joy2Y);
joy1Xs = analogRead(joy1X);
joy1Bs = digitalRead(joy1B);
joy1Ys = analogRead(joy1Y);
percentagefinished();
// screen initialization
percentagefinished();
rrate = EEPROM.read(EEPROMRR);
refreshrate = 1000 / rrate;
// rrate = refreshrate
percentagefinished();
g3highscore = EEPROM.read(EEPROMG3HS);
percentagefinished();
g2highscore = EEPROM.read(EEPROMG2HS);
percentagefinished();
g1highscore = EEPROM.read(EEPROMG1HS);
percentagefinished();
timereset();
percentagefinished();
Version();
}
if (bank == true) {
if (value1 == 2) {
Lockdown = true;
Serial.print("Please Try Again In ");
Serial.print(left);
Serial.println(" Minutes.");
}
if (left == 1) {
Serial.println("SODK");
Lockdown = true;
}
if (Lockdown == false) {
Serial.println("Please Enter Username");
}
if (fails == 1) {
t = 1;
}
if (fails == 2) {
t = 3;
}
if (fails == 3) {
t = 5;
}
if (fails == 4) {
t = 10;
}
if (fails == 5) {
t = 15;
}
if (fails == 6) {
t = 30;
}
if (fails == 7) {
t = 60;
}
if (Lockdown == true) {
Serial.print("Please Wait ");
Serial.print(fails);
Serial.println(" Minutes.");
}
}
if (bank == false) {
delay(750);
if (developermode == true) {
serialconnected = true;
} else Serial.println("Please Type 'Activate Serial Feedback' to Activate Serial Feedback");
}
}
void blankline(int int1) {
for (int int2 = 0; int2 < int1; int2 = int2 + 1) {
if (serialconnected == true) {
Serial.println("0");
}
}
}
void handleEncoderInterrupt() {
int pinAState = digitalRead(encoderPinA);
int pinBState = digitalRead(encoderPinB);
if (pinAState == pinBState) {
encoderPosition++;
} else {
encoderPosition--;
}
encoderTwisted = true;
}
void allon() {
if (Light == true) {
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led8, HIGH);
digitalWrite(led9, HIGH);
digitalWrite(led10, HIGH);
}
}
void alloff() {
if (Light == true) {
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led5, LOW);
digitalWrite(led6, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
digitalWrite(led9, LOW);
digitalWrite(led10, LOW);
}
}
void sensorcheck() {
touch1s = digitalRead(touch1);
touch2s = digitalRead(touch2);
touch3s = digitalRead(touch3);
joy1Bs = digitalRead(joy1B);
joy2Bs = digitalRead(joy2B);
greenBs = digitalRead(greenB);
rotaryBs = digitalRead(rotaryB);
redBs = digitalRead(redB);
yellowBs = digitalRead(yellowB);
rotaryBs = digitalRead(rotarybutton);
yellowbs = digitalRead(yellowB);
twisters = digitalRead(rotaryB);
joy2Xs = analogRead(joy2X);
joy2Bs = digitalRead(joy2B);
joy2Ys = analogRead(joy2Y);
joy1Xs = analogRead(joy1X);
joy1Bs = digitalRead(joy1B);
joy1Ys = analogRead(joy1Y);
rotary2s = digitalRead(rotary2);
rotary1s = digitalRead(rotary1);
redbs = digitalRead(redB);
joy2bs = digitalRead(joy2B);
joy2bs = digitalRead(joy2B);
// back();
}
void lickes() {
allon();
if (nosound == false) {
tone(buzzer, 500, 200);
}
delay(200);
alloff();
}
int cor7 = 0;
int g1 = 4;
int c2 = 2;
int c = 8;
int epromg1hs = 1;
int epromg2hs = 2;
int epromg3hs = 3;
int counter3 = 0;
int counter2 = 0;
int refreshcounter = 0;
int something;
int rint = 1;
int int3 = 2;
int game = 2;
int cor = 7;
int cor1 = 1;
int cor11 = 4;
int cor2 = 3;
int cor3 = 0;
int cor4 = 0;
int cor41 = 5;
int cor5 = 1;
int cor51 = 0;
int cor52 = 8;
int cor6 = 1; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
int cor9 = 1;
int cor91 = 3;
int int1 = 12;
int int7 = 5;
int int6 = 1;
int cor61 = 1;
int int5 = 16;
int int51 = 14;
int int52 = 12;
int int8 = 0;
int game2delay = refreshrate;
int counter = 1;
int game1score = 0;
int cor4g1 = 0;
int g3score;
int game3totalfound = 0;
int refresh = 1000 / refreshrate;
int intrefresh = refreshrate / 1;
int scounter;
bool confirmreset = false;
bool game2over = false;
bool game2s = false;
bool G1HS = false;
bool G2HS = false;
bool G3HS = false;
bool lockdown = false;
bool bool4 = false;
bool backS = false;
bool SaveS = false;
bool newscore = false;
bool refreshnow = false;
bool startup = true;
bool gameselection = false;
bool repeatonce = true;
bool gameover = false;
bool gaming = false;
bool clicked = false;
bool countdown = false;
bool proceedgame1 = false;
bool putina0 = false;
bool first = true;
bool game1 = false;
bool game2 = false;
bool game3 = false;
bool notimer = false;
bool timer = false;
bool settings = false;
bool refreshchange = false;
bool highscores = false;
bool gamesorsettings = false;
bool activategame1 = false;
bool activategame2 = false;
bool activategame3 = false;
bool f1 = true;
bool f2 = true;
bool f3 = true;
bool f4 = true;
bool X1 = true;
bool X2 = false;
bool backRR = false;
bool SaveRR = false;
bool SOUND = false;
bool LIGHTS = false;
bool TIME = false;
bool G1T = false;
bool G2T = false;
bool G3T = false;
void gameboolsreset() {
bool f1 = false;
bool f2 = false;
bool f3 = false;
bool f4 = false;
}
void allfalse() {
backS = false;
SaveS = false;
G3T = false;
G2T = false;
G1T = false;
TIME = false;
confirmreset = false;
game2s = false;
game2over = false;
LIGHTS = false;
SOUND = false;
G1HS = false;
G2HS = false;
G3HS = false;
backRR = false;
SaveRR = false;
bool4 = false;
newscore = false;
refreshnow = false;
gameselection = false;
repeatonce = false;
gameover = false;
gaming = false;
clicked = false;
countdown = false;
proceedgame1 = false;
putina0 = false;
first = true;
game1 = false;
game2 = false;
game3 = false;
notimer = false;
timer = false;
settings = false;
refreshchange = false;
highscores = false;
gamesorsettings = false;
activategame1 = false;
activategame2 = false;
activategame3 = false;
startup = false;
startup = false;
repeatonce = true;
gameover = false;
gaming = false;
clicked = false;
countdown = false;
proceedgame1 = false;
putina0 = false;
first = true;
game1 = false;
game2 = false;
game3 = false;
notimer = false;
timer = false;
settings = false;
refreshchange = false;
highscores = false;
gamesorsettings = false;
activategame1 = false;
activategame2 = false;
activategame3 = false;
}
void refreshb() {
delay(refreshrate);
lcd.clear();
}
void back() {
sensorcheck();
if ((joy1Bs == LOW && joy2Bs == LOW) || ((redbs == LOW || yellowbs == LOW || greenbs == HIGH || touch1s == HIGH || touch2s == HIGH || touch3s == HIGH) && (timer == false && notimer == false && gaming == false)) && gamesorsettings == false) {
if (nosound == false) {
tone(buzzer, 500, 200);
}
allon();
delay(200);
allfalse();
gamesorsettings = true;
lcd.clear();
if (serialconnected == true) {
Serial.println("Returned to main screen");
}
alloff();
}
}
void loop() {
unsigned long currentTime = millis();
// start screen
if (bank == false) {
if (startup == true) {
alloff();
lcd.setCursor(0, 0);
lcd.print("Press Any Button");
lcd.setCursor(0, 1);
lcd.print(" To Start ");
sensorcheck();
if (repeatonce == true) {
if (serialconnected == true) {
Serial.println("Start Screen");
}
repeatonce = false;
}
if (touch1s == HIGH || touch2s == HIGH || touch3s == HIGH || joy1Bs == LOW || joy2Bs == LOW || redBs == LOW || yellowBs == LOW || greenBs == LOW || rotaryBs == HIGH || rotaryBs == HIGH) {
lickes();
if (serialconnected == true) {
Serial.println("Choosing Game or Settings");
}
lcd.clear();
delay(refresh);
startup = false;
gamesorsettings = true;
repeatonce = true;
}
}
// selection screen
if (gamesorsettings == true) {
alloff();
back();
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Mode Selection");
lcd.setCursor(1, 1);
lcd.print("Games");
lcd.setCursor(9, 1);
lcd.print("Settng");
lcd.setCursor(cor2 - 4, 1);
lcd.print(">");
lcd.setCursor(cor2 + 3, 1);
lcd.print("<");
sensorcheck();
// movement checks
if (joy1Ys < 400 || joy2Ys < 400) {
cor2 = cor2 + 9;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor2 = cor2 - 9;
}
if (cor2 > 14) {
cor2 = 12;
}
if (cor2 < 2) {
cor2 = 3;
}
//selector
if ((joy1Bs == LOW || joy2Bs == LOW) && cor2 == 3) {
allfalse();
gameselection = true;
lcd.clear();
if (serialconnected == true) {
Serial.println("Games Chosen");
}
lickes();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor2 == 12) {
allfalse();
settings = true;
lcd.clear();
if (serialconnected == true) {
Serial.println("Settings Chosen");
}
lickes();
}
back();
refreshb();
}
// settings
if (settings == true) {
refreshb();
back();
sensorcheck();
if ((joy1Ys < 400 || joy2Xs < 400) && (cor3 == 0)) {
cor7 = cor7 - 1;
} else if (joy1Ys > 700 || joy2Xs > 700) {
cor3 = cor3 + 1;
}
if ((joy1Ys > 700 || joy2Xs > 700) && cor3 > 0) {
cor7 = cor7 + 1;
} else if (joy1Ys < 400 || joy2Xs < 400) {
cor3 = cor3 - 1;
}
if (cor3 == 1 && (joy1Ys < 400 || joy2Xs < 400)) {
cor7 = 1;
}
if (cor3 > 4) {
cor3 = 4;
}
if (cor3 < 0) {
cor3 = 0;
}
if (cor7 > 1) {
cor7 = 1;
}
if (cor7 < 0) {
cor7 = 0;
}
if (cor3 == 0 || cor3 == 1) {
lcd.setCursor(2, 0);
lcd.print("High Scores");
lcd.setCursor(2, 4);
lcd.print(" Sound");
} else if (cor3 == 2) {
lcd.clear();
lcd.setCursor(2, 0);
lcd.print(" Sound");
lcd.setCursor(2, 1);
lcd.print(" Refresh");
} else if (cor3 == 3) {
lcd.clear();
lcd.setCursor(2, 0);
lcd.print(" Refresh");
lcd.setCursor(2, 1);
lcd.print(" Lights");
} else if (cor3 == 4) {
lcd.clear();
lcd.setCursor(2, 0);
lcd.print(" Lights");
lcd.setCursor(2, 1);
lcd.print(" Reset");
}
lcd.setCursor(0, cor7);
lcd.print("->");
lcd.setCursor(14, cor7);
lcd.print("<-");
// selection phase
sensorcheck();
if ((joy1Bs == LOW || joy2Bs == LOW) && ((cor7 == 0 && cor3 == 3) || (cor7 == 1 && cor3 == 2))) {
delay(250);
allfalse();
refreshchange = true;
lcd.clear();
if (serialconnected == true) {
Serial.println("Changing Refresh Settings");
}
lickes();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && (cor3 == 0 || cor3 == 1) && cor7 == 0) {
delay(250);
allfalse();
highscores = true;
lcd.clear();
if (serialconnected == true) {
Serial.println("Checking High Scores");
}
lickes();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor3 == 4 && cor7 == 1) {
delay(250);
allfalse();
TIME = true;
lcd.clear();
if (serialconnected == true) {
Serial.println("Possible Reset");
}
lickes();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && ((cor3 == 4 && cor7 == 0) || (cor3 == 3 && cor7 == 1))) {
delay(250);
allfalse();
LIGHTS = true;
lcd.clear();
if (serialconnected == true) {
Serial.println("Changing Light Settings");
}
lickes();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && (((cor3 == 0 || cor3 == 1) && cor7 == 1) || (cor3 == 3 && cor7 == 0))) {
delay(250);
allfalse();
lcd.clear();
SOUND = true;
if (serialconnected == true) {
Serial.println("Changing Sound Settings");
}
lickes();
}
}
if (TIME == true) {
back();
refreshb();
sensorcheck();
lcd.setCursor(4, 0);
lcd.print("Reset?");
lcd.setCursor(2, 1);
lcd.print("Yes");
lcd.setCursor(12, 1);
lcd.print("No");
sensorcheck();
lcd.setCursor(cor1, 1);
lcd.print(">");
lcd.setCursor(cor1 + cor11, 1);
lcd.print("<");
if (cor1 == 1 && (joy1Bs == LOW || joy2Bs == LOW)) {
lickes();
lcd.clear();
Serial.print("SAVING");
lcd.print("SAVING");
for (int i = 0; i < random(3, 15); i++) {
delay(300);
lcd.print(".");
Serial.print(".");
}
Serial.println();
delay(random(1, 500));
lcd.clear();
lcd.print("RESETING");
Serial.print("RESETING");
Serial.println();
Serial.println();
delay(400);
resetFunc();
}
if (cor1 == 11 && (joy1Bs == LOW || joy2Bs == LOW)) {
lickes();
allfalse();
TIME = false;
settings = true;
}
if (joy1Ys < 400 || joy2Ys < 400) {
cor1 = 11;
cor11 = 3;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor1 = 1;
cor11 = 4;
}
//cor1
}
if (LIGHTS == true) {
refreshb();
lcd.setCursor(5, 0);
lcd.print("Lights");
lcd.setCursor(2, 1);
lcd.print("ON");
lcd.setCursor(11, 1);
lcd.print("OFF");
lcd.setCursor(cor9, 1);
lcd.print(">");
lcd.setCursor(cor9 + cor91, 1);
lcd.print("<");
sensorcheck();
if (cor9 == 1 && (joy1Bs == LOW || joy2Bs == LOW)) {
Light = true;
allfalse();
settings = true;
EEPROM.update(112, 1);
}
if (cor9 == 10 && (joy1Bs == LOW || joy2Bs == LOW)) {
Light = false;
allfalse();
settings = true;
EEPROM.update(112, 2);
}
if (joy1Ys < 400 || joy2Ys < 400) {
cor9 = 10;
cor91 = 4;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor9 = 1;
cor91 = 3;
}
}
if (SOUND == true) {
refreshb();
lcd.setCursor(5, 0);
lcd.print("SOUND"); /////////////////////////////////////////////////////////////////////////////////////////////////////////////
lcd.setCursor(2, 1);
lcd.print("ON");
lcd.setCursor(11, 1);
lcd.print("OFF");
lcd.setCursor(cor9, 1);
lcd.print(">");
lcd.setCursor(cor9 + cor91, 1);
lcd.print("<");
sensorcheck();
if (cor9 == 10 && (joy1Bs == LOW || joy2Bs == LOW)) {
nosound = true;
allfalse();
settings = true;
EEPROM.update(111, 1);
}
if (cor9 == 1 && (joy1Bs == LOW || joy2Bs == LOW)) {
nosound = false;
allfalse();
settings = true;
EEPROM.update(111, 2);
}
if (joy1Ys < 400 || joy2Ys < 400) {
cor9 = 10;
cor91 = 4;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor9 = 1;
cor91 = 3;
}
}
if (refreshchange == true) {
back();
refreshb();
lcd.setCursor(2, 0);
lcd.print(rrate - 1);
lcd.setCursor(13, 0);
lcd.print(rrate + 1);
lcd.setCursor(2, 1);
lcd.print("Save");
lcd.setCursor(10, 1);
lcd.print("Back");
lcd.setCursor(7, 0);
lcd.print(rrate);
sensorcheck();
if (X1 == true) {
if (joy1Ys < 400 || joy2Ys < 400) {
rrate = rrate + 1;
}
if (joy1Ys > 700 || joy2Ys > 700) {
rrate = rrate - 1;
}
lcd.setCursor(6, 0);
lcd.print("[");
lcd.setCursor(c, 0);
lcd.print("]");
}
if (X2 == true) {
if (joy1Ys < 400 || joy2Ys < 400) {
cor5 = 9;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor5 = 1;
}
lcd.setCursor(cor5, 1);
lcd.print(">");
lcd.setCursor(cor5 + 5, 1);
lcd.print("< ");
}
if ((joy1Bs == LOW || joy2Bs == LOW) && X2 == true && cor5 == 9) {
lickes();
backRR = true;
refreshchange = false;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && X2 == true && cor5 == 1) {
lickes();
SaveRR = true;
allon();
refreshchange = false;
}
if (joy1Xs < 400 || joy2Xs < 400) {
X1 = true;
X2 = false;
}
if (joy1Xs > 700 || joy2Xs > 700) {
X1 = false;
X2 = true;
}
if (rrate < 1) {
rrate = 1;
}
if (rrate > 9) {
c = 9;
c2 = 1;
} else c = 8;
c2 = 2;
back();
}
if (backRR == true) {
settings = true;
backRR = false;
alloff();
}
if (SaveRR == true) {
refreshb();
if (rrate > 9) {
c2 = 1;
} else c2 = 2;
lcd.setCursor(c2, 0);
lcd.print(rrate);
lcd.print(" Per Second ? ");
lcd.setCursor(2, 1);
lcd.print("Yes");
lcd.setCursor(12, 1);
lcd.print("No");
lcd.setCursor(cor6, 1);
lcd.print(" > ");
lcd.setCursor(cor6 + g1, 1);
lcd.print(" < ");
sensorcheck();
if (joy1Ys < 400 || joy2Ys < 400) {
g1 = 3;
cor6 = 11;
}
if (joy1Ys > 700 || joy2Ys > 700) {
g1 = 4;
cor6 = 1;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor6 == 11) {
SaveRR = false;
settings = true;
if (serialconnected == true) {
Serial.println("Action Canceled");
}
alloff();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor6 == 1) {
SaveRR = false;
refreshrate = 1000 / rrate;
lcd.clear();
lcd.print("Saving");
delay(random(250, 750));
lcd.clear();
X1 = true;
X2 = false;
gamesorsettings = true;
if (serialconnected == true) {
Serial.print("Refresh Rate Saved As ");
Serial.print(rrate);
Serial.println(" Per Second");
}
alloff();
EEPROM.update(EEPROMRR, rrate);
}
}
if (highscores == true) {
back();
refreshb();
lcd.setCursor(2, 0);
lcd.print("High Scores");
lcd.setCursor(2, 1);
lcd.print("1");
lcd.setCursor(7, 1);
lcd.print("2");
lcd.setCursor(12, 1);
lcd.print("3");
lcd.setCursor(cor6, 1);
lcd.print("[");
lcd.setCursor(cor6 + 2, 1);
lcd.print("]");
sensorcheck();
if (joy1Ys < 400 || joy2Ys < 400) {
cor6 = cor6 + 5;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor6 = cor6 - 5;
}
if (cor6 > 12) {
cor6 = 11;
}
if (cor6 < 3) {
cor6 = 1;
}
sensorcheck();
if ((joy1Bs == LOW || joy2Bs == LOW) && cor6 == 1) {
highscores = false;
allfalse();
G1HS = true;
if (serialconnected == true) {
Serial.println("G1HS");
}
lickes();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor6 == 6) {
highscores = false;
allfalse();
G2HS = true;
if (serialconnected == true) {
Serial.println("G2HS");
}
lickes();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor6 == 11) {
highscores = false;
allfalse();
G3HS = true;
if (serialconnected == true) {
Serial.println("G3HS");
}
lickes();
}
back();
}
if (G3HS == true) {
back();
refreshb();
lcd.setCursor(0, 0);
lcd.print("Game 3 Hih Score");
lcd.setCursor(7, 1);
lcd.print(g3highscore);
}
if (G2HS == true) {
back();
refreshb();
lcd.setCursor(0, 0);
lcd.print("Game 2 Hih Score");
lcd.setCursor(7, 1);
lcd.print(g2highscore);
}
if (G1HS == true) {
back();
refreshb();
lcd.setCursor(0, 0);
lcd.print("Game 1 Hih Score");
lcd.setCursor(7, 1);
lcd.print(g1highscore);
}
// game selection
if (gameselection == true) {
sensorcheck();
refreshb(); ///////////////////////////////////////////////////////////////////////////////////////////////
back();
if (repeatonce == true) {
Serial.println("GAME SCREEN");
repeatonce = false;
}
lcd.print(" Game Selection");
lcd.setCursor(2, 1);
lcd.print("1");
lcd.setCursor(7, 1);
lcd.print("2");
lcd.setCursor(12, 1);
lcd.print("3");
lcd.setCursor(cor - 1, 1);
lcd.print(">");
lcd.setCursor(cor + 1, 1);
lcd.print("<");
if (joy1Ys < 400 || joy2Ys < 400) {
cor = cor + 5;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor = cor - 5;
}
if (cor > 13) {
cor = 12;
}
if (cor < 3) {
cor = 2;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor == 2) {
allfalse();
lickes();
activategame1 = true;
lcd.clear();
repeatonce = true;
Serial.println("Game 1 Chosen");
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor == 7) {
allfalse();
lickes();
activategame2 = true;
lcd.clear();
repeatonce = true;
Serial.println("Game 2 Chosen");
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor == 12) {
allfalse();
lickes();
activategame3 = true;
lcd.clear();
repeatonce = true;
Serial.println("Game 3 Chosen");
}
}
if (activategame1 == true) {
allfalse();
activategame1 = true;
back();
refreshb();
lcd.setCursor(4, 0);
lcd.print("Game 1? ");
lcd.setCursor(2, 1);
lcd.print("Yes");
lcd.setCursor(11, 1);
lcd.print("No");
lcd.setCursor(cor4g1, 1);
lcd.print("->");
lcd.setCursor(cor4g1 + cor41, 1);
lcd.print("<-");
back();
delay(300);
sensorcheck();
// movement checks
if (joy1Ys < 400 || joy2Ys < 400) {
cor41 = 4;
cor4g1 = 9;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor41 = 5;
cor4g1 = 0;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor4g1 == 0) {
lickes();
proceedgame1 = true;
countdown = true;
activategame1 = false;
lcd.clear();
timereset();
delay(300);
if (serialconnected == true) {
Serial.println("Choice Confirmed as Yes");
Serial.println("Starting Countdown to Game 1");
}
repeatonce = true;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor4g1 == 9) {
lickes();
gameselection = true;
activategame1 = false;
lcd.clear();
timereset();
delay(300);
repeatonce = true;
if (serialconnected == true) {
Serial.println("Choice Confirmed as No");
Serial.println("Decided Aginst Game 1 Returning to Main Menu");
}
}
}
if (proceedgame1 == true) {
back();
gameselection = false;
if (countdown == true) {
back();
lcd.clear();
lcd.print(" Game 1");
back();
lcd.setCursor(7, 1);
lcd.print("3");
if (Light == true) {
digitalWrite(led1, HIGH);
digitalWrite(led5, HIGH);
digitalWrite(led10, HIGH);
}
if (nosound == false) {
tone(buzzer, 750, 450);
}
delay(450);
if (Light == true) {
digitalWrite(led1, LOW);
digitalWrite(led5, LOW);
digitalWrite(led10, LOW);
}
delay(550);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Game 1");
back();
lcd.setCursor(7, 1);
lcd.print("2");
if (Light == true) {
digitalWrite(led2, HIGH);
digitalWrite(led6, HIGH);
digitalWrite(led9, HIGH);
}
if (nosound == false) {
tone(buzzer, 750, 450);
}
delay(450);
if (Light == true) {
digitalWrite(led2, LOW);
digitalWrite(led6, LOW);
digitalWrite(led9, LOW);
}
delay(550);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Game 1");
back();
lcd.setCursor(7, 1);
lcd.print("1");
if (Light == true) {
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led7, HIGH);
digitalWrite(led8, HIGH);
}
if (nosound == false) {
tone(buzzer, 750, 450);
}
delay(450);
if (Light == true) {
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
digitalWrite(led7, LOW);
digitalWrite(led8, LOW);
}
delay(550);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Game 1");
back();
lcd.setCursor(6, 1);
lcd.print("GO!");
if (nosound == false) {
tone(buzzer, 900, 900);
}
allon();
delay(900);
alloff();
delay(100);
clicked = true;
gaming = true;
countdown = false;
if (serialconnected == true) {
Serial.println("Game 1 Countdown Finished");
}
back();
}
if (gaming == true) {
back();
lcd.clear();
something = something + 1;
lcd.setCursor(0, 0);
lcd.print(minutes1);
lcd.print(" : ");
if (bool4 == true) {
lcd.setCursor(2, 0);
lcd.print("0");
}
lcd.setCursor(int1, 0);
lcd.print(seconds1);
lcd.setCursor(8, 0);
lcd.print("Score : ");
lcd.print(game1score);
lcd.setCursor(0, 1);
lcd.print(game1words[rint]);
counter3 = counter3 + 1;
counter2 = counter2 + 1;
if (counter2 > 4) {
counter2 = 0;
seconds1 = seconds1 - 1;
if (nosound == false) {
tone(buzzer, 400, 100);
}
delay(100);
}
if (counter3 > 10) {
counter3 = 0;
rint = random(1, 23);
}
sensorcheck();
if (game1words[rint] == " Twist It") {
if (counter2 == 1) {
if (serialconnected == true) {
Serial.println("Twister");
}
}
if (encoderTwisted == true) {
game1score = game1score + 1;
counter = 2;
rint = random(1, 23);
if (serialconnected == true) {
Serial.println("Twister scored");
}
if (Light == true) {
digitalWrite(led1, HIGH);
digitalWrite(led5, HIGH);
}
} else
digitalWrite(led1, LOW);
digitalWrite(led5, LOW);
}
sensorcheck();
if (game1words[rint] == " Touch It") {
if (counter2 == 1) {
if (serialconnected == true) {
Serial.println("Touch");
}
}
if (touch1s == HIGH || touch2s == LOW || touch3s == LOW) {
game1score = game1score + 1;
counter = 2;
rint = random(1, 23);
if (serialconnected == true) {
Serial.println("Touch scored");
}
if (Light == true) {
digitalWrite(led2, HIGH);
digitalWrite(led6, HIGH);
}
} else
digitalWrite(led2, LOW);
digitalWrite(led6, LOW);
}
sensorcheck();
if (game1words[rint] == " Click It") {
if (counter2 == 1) {
if (serialconnected == true) {
Serial.println("Button");
}
}
if (redBs == LOW || yellowBs == LOW || greenBs == LOW) {
game1score = game1score + 1;
counter = 2;
rint = random(1, 23);
if (serialconnected == true) {
Serial.println("Button scored");
}
if (Light == true) {
digitalWrite(led3, HIGH);
digitalWrite(led7, HIGH);
}
} else
digitalWrite(led3, LOW);
digitalWrite(led7, LOW);
}
sensorcheck();
if (game1words[rint] == " Flick It") {
if (counter2 == 1) {
if (serialconnected == true) {
Serial.println("Flick");
Serial.println("Flick error ask about");
}
}
//game1score = game1score + 1;
}
sensorcheck();
if (game1words[rint] == "Pres the Joystick") {
if (counter2 == 1) {
if (serialconnected == true) {
Serial.println("Joystick");
}
}
if (joy1Bs == LOW || joy2Bs == LOW) {
game1score = game1score + 1;
counter = 2;
rint = random(1, 23);
if (serialconnected == true) {
Serial.println("Joystick Scored");
}
}
}
if (seconds1 < 10) {
int1 = 3;
bool4 = true;
} else int1 = 2;
bool4 = false;
if (minutes1 == 0 && seconds1 == 0) {
lcd.clear();
gaming = false;
if (g1highscore < game1score) {
g1highscore = game1score;
newscore = true;
gameover = false;
} else
gameover = true;
newscore = false;
}
if (seconds1 == 0) {
seconds1 = 59;
minutes1 = minutes1 - 1;
}
counter = counter + 1;
if (gameover == true) {
back();
lcd.clear();
lcd.print(" Game Over");
delay(300);
back();
if (serialconnected == true) {
Serial.println("Game 1 Over");
}
delay(700);
back();
lcd.clear();
lcd.print(" Game Over");
lcd.setCursor(0, 1);
lcd.print(" Your Score : ");
lcd.print(game1score);
delay(2500);
back();
lcd.clear();
lcd.print("Your Score : ");
lcd.print(game1score);
lcd.setCursor(0, 1);
lcd.print("High Score : ");
lcd.print(g1highscore);
delay(2500);
back();
}
if (counter > 10) {
rint = random(1, 23);
if (rint > 23) {
rint = random(1, 23);
}
counter = 1;
}
if (newscore == true) {
back();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("highscore");
if (Light == true) {
digitalWrite(led5, HIGH);
}
delay(300);
digitalWrite(led5, LOW);
}
delay(250);
}
}
if (activategame2 == true) { //////////////////////////////////////////////////////////////////////////////////////////////////////////
allfalse();
activategame1 = true;
back();
refreshb();
lcd.setCursor(4, 0);
lcd.print("Game 2? ");
lcd.setCursor(2, 1);
lcd.print("Yes");
lcd.setCursor(11, 1);
lcd.print("No");
lcd.setCursor(cor4g1, 1);
lcd.print("->");
lcd.setCursor(cor4g1 + cor41, 1);
lcd.print("<-");
back();
delay(300);
sensorcheck();
// movement checks
if (joy1Ys < 400 || joy2Ys < 400) {
cor41 = 4;
cor4g1 = 9;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor41 = 5;
cor4g1 = 0;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor4g1 == 0) {
lickes();
allfalse();
game2s = true;
lcd.clear();
timereset();
delay(300);
if (serialconnected == true) {
Serial.println("Choice Confirmed as Yes");
Serial.println("Starting Countdown to Game 2");
}
repeatonce = true;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor4g1 == 9) {
lickes();
gameselection = true;
activategame2 = false;
lcd.clear();
timereset();
delay(300);
repeatonce = true;
if (serialconnected == true) {
Serial.println("Choice Confirmed as No");
Serial.println("Decided Aginst Game 2 Returning to Main Menu");
}
}
//spare bool game2s
}
if (game2s == true) {
}
if (activategame3 == true) {
back();
lcd.clear();
lcd.print(" Click As Many");
lcd.setCursor(0, 1);
lcd.print(" Buttons As");
delay(1500);
back();
lcd.clear();
lcd.print(" Possible");
delay(1500);
back();
game3 = true;
activategame3 = false;
repeatonce = true;
lcd.print("Forwarding To Game 3");
}
if (game3 == true) {
if (repeatonce == true) {
back();
if (serialconnected == true) {
Serial.println("Succesfully Forwarded to Game 3");
Serial.println("Game 3 Chosen, Choosing Timer");
}
repeatonce = false;
}
if (Serial.available()) {
command = Serial.readStringUntil('\n');
command.trim();
if (command.equals("timer") || command.equals("yes")) {
timer = true;
game3 = false;
notimer = false;
}
if (command.equals("no timer") || command.equals("no")) {
timer = false;
game3 = false;
notimer = true;
}
}
back();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Play With Timer ? ");
lcd.setCursor(2, 1);
lcd.print("Yes");
lcd.setCursor(12, 1);
lcd.print("No");
lcd.setCursor(cor4, 1);
lcd.print("->");
lcd.setCursor(cor4 + int7, 1);
lcd.print(" < -");
delay(300);
sensorcheck();
// movement checks
if (joy1Ys < 400 || joy2Ys < 400) {
cor4 = 10;
int7 = 4;
}
if (joy1Ys > 700 || joy2Ys > 700) {
cor4 = 0;
int7 = 5;
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor4 == 9) {
notimer = true;
game3 = false;
timer = false;
Serial.println("Game 3 Without Timer");
lcd.clear();
delay(300);
repeatonce = true;
lickes();
lcd.clear();
}
if ((joy1Bs == LOW || joy2Bs == LOW) && cor4 == 0) {
notimer = false;
game3 = false;
timer = true;
first = true;
lcd.clear();
delay(300);
Serial.println("Game 3 With Timer");
repeatonce = true;
lickes();
lcd.clear();
}
}
if (notimer == true) {
int thing = (100 / 81) * game3totalfound;
lcd.setCursor(0, 0);
lcd.print(" Find It!");
lcd.setCursor(0, 1);
lcd.print("Found : ");
lcd.print(game3totalfound);
back();
sensorcheck();
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (timer == true) {
refreshb();
lcd.clear();
back();
if (first == true) {
back();
something = something + 1;
if (seconds3 < 10) {
int1 = 13;
} else int1 = 12;
lcd.setCursor(0, 0);
lcd.print("Time Left");
lcd.setCursor(10, 0);
lcd.print(minutes3);
lcd.print(" : ");
lcd.setCursor(int1, 0);
lcd.print(seconds3);
lcd.setCursor(0, 1);
lcd.print("Clicked : ");
lcd.print(game3totalfound);
sensorcheck();
if (touch1s == HIGH || touch2s == HIGH) {
alloff();
if (Light == true) {
digitalWrite(rlights[random(1, 29)], HIGH);
digitalWrite(rlights[random(1, 29)], HIGH);
}
g3score = g3score + 1;
game3totalfound = game3totalfound + 1;
if (nosound == false) {
tone(buzzer, 500, 200);
}
}
if (touch3s == HIGH || joy1Bs == LOW) {
alloff();
if (Light == true) {
digitalWrite(rlights[random(1, 29)], HIGH);
digitalWrite(rlights[random(1, 29)], HIGH);
}
g3score = g3score + 1;
game3totalfound = game3totalfound + 1;
if (nosound == false) {
tone(buzzer, 500, 200);
}
}
if (joy2Bs == LOW || greenBs == LOW) {
alloff();
if (Light == true) {
digitalWrite(rlights[random(1, 29)], HIGH);
digitalWrite(rlights[random(1, 29)], HIGH);
}
g3score = g3score + 1;
game3totalfound = game3totalfound + 1;
if (nosound == false) {
tone(buzzer, 500, 200);
}
}
if (yellowBs == LOW || redBs == LOW || rotaryBs == LOW) {
alloff();
if (Light == true) {
digitalWrite(rlights[random(1, 29)], HIGH);
digitalWrite(rlights[random(1, 29)], HIGH);
}
g3score = g3score + 1;
game3totalfound = game3totalfound + 1;
if (nosound == false) {
tone(buzzer, 500, 200);
}
}
if (something == rrate) {
something = 0;
seconds3 = seconds3 - 1;
}
if (seconds3 == 0) {
seconds3 = 59;
minutes3 = minutes3 - 1;
}
}
if (minutes3 == 0 && seconds3 == 1) {
if (repeatonce == true) {
lcd.clear();
back();
Serial.println("Game Over");
allfalse();
}
if (game3totalfound > g3highscore) {
alloff();
refreshb();
Serial.println("NEW HIGH SCORE!");
if (repeatonce == true) {
EEPROM.update(G3HS, game3totalfound);
lcd.print("NEW HIGH SCORE!");
}
lcd.setCursor(7, 1);
lcd.print(g3score);
back();
first = false;
EEPROM.update(G3HS, game3totalfound);
}
if (game3totalfound < g3highscore) {
alloff();
first = false;
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("GAME OVER");
lcd.setCursor(0, 1);
lcd.print(" Your Score : ");
lcd.print(g3score);
back();
delay(2000);
back();
game3totalfound = 0;
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("GAME OVER");
lcd.setCursor(0, 1);
lcd.print(" High Score: ");
lcd.print(g3highscore);
back();
delay(2000);
back();
first = false;
lcd.clear();
lcd.print(" Push Joysticks");
lcd.setCursor(0, 1);
lcd.print("To Go Main Menu");
back();
delay(2000);
back();
}
}
back();
}
}
if ((Serial.available() || Serial2.available())) {
command = Serial.readStringUntil('\n');
command.trim();
if (bank == false) {
if (command.equals("back") || command.equals("home")) {
allfalse();
timereset();
startup = true;
Serial.println("Returning to main screen");
repeatonce = true;
sentcommands();
} else if (command.equals("game 3")) {
allfalse();
activategame3 = true;
sentcommands();
} else if (command.equals("game 1 straight") || command.equals("game 1 overide")) {
allfalse();
countdown = true;
proceedgame1 = true;
gaming = true;
sentcommands();
} else if (command.equals("game 1")) {
allfalse();
activategame1 = true;
sentcommands();
} else if (command.equals("game 2")) {
allfalse();
activategame2 = true;
game2s = true;
sentcommands();
} else if (command.equals("begin") || command.equals("start") || command.equals("Begin") || command.equals("Start")) {
allfalse();
timereset();
gamesorsettings = true;
repeatonce = true;
sentcommands();
} else if (command.equals("Please")) {
g1highscore = 7500;
EEPROM.read(game1hs);
Serial.println(game1hs);
lcd.print(game1hs);
sentcommands();
} else if (command.equals("game 3 with timer") || command.equals("game 3 w timer")) {
allfalse();
minutes3 = 2;
seconds3 = 59;
game3totalfound = 0;
timer = true;
sentcommands();
lcd.clear();
} else if (command.equals("game 3 with out timer") || command.equals("game 3 w / o timer") || command.equals("game 3 no timer")) {
allfalse();
notimer = true;
sentcommands();
} else if (command.equals("HELP")) {
Serial.println();
if (developermode == true) {
sentcommands();
}
Serial.println("Type Sound Or Lights On Or Off");
delay(750);
Serial.println("Type What Game You Would Like To Go To");
delay(750);
Serial.println("'Reset' Restarts Board With Data Saved");
delay(750);
Serial.println("'Home' Brings You Back To The Home Screen");
if (developermode == true) {
delay(750);
Serial.println("Type 'Notes' For Programming Notes");
delay(750);
Serial.println("Type 'Bool Check' For Active Booleans");
delay(750);
Serial.println("Type 'Sensor Check' For List Of Sensor States");
}
} else if (command.equals("DeveloperReagan Off") || command.equals("Developer Reagan Off")) {
Serial.println();
Serial.println("Developer Mode Off");
Serial.println("RESETING");
delay(150);
serialconnected = true;
developermode = false;
EEPROM.update(114, 2);
resetFunc();
} else if ((command.equals("Time ? ") || command.equals("time ? ")) && timer == true) {
sentcommands();
Serial.print(minutes3);
Serial.print(" : ");
Serial.println(seconds3);
} else if (command.equals("63Mininto1") && timer == true) {
minutes3 = 0;
seconds3 = 15;
Serial.println("Cheat Code Accepted");
Serial.println("Time Changed");
} else if (command.equals("Version ? ") || command.equals("Version") || command.equals("version")
|| command.equals("version ? ")) {
Serial.println();
Serial.println("Need to fix game 2");
Serial.println("HELP Function Built");
Serial.println("Added lights on and off serial commands");
Serial.println("Added Developer Mode");
Serial.println("work to debug game 1");
Serial.println("debugged settings and replaced time with reset");
Serial.println("Added manual reset option");
Serial.println();
Serial.println("Version 1.2.1");
Serial.println();
Serial.print("Upload ");
Serial.println(versions);
} else if (command.equals("No Sound")) {
nosound = true;
EEPROM.update(111, 1);
Serial.println("Accepted. Sound Turned Off.");
} else if (command.equals("Sound On")) {
nosound = false;
EEPROM.update(111, 2);
Serial.println("Accepted. Sound Turned On.");
} else if (command.equals("No Lights")) {
Light = false; //////////////////////////////////////////////////////////////////////////////////////////////////////
EEPROM.update(112, 1);
Serial.println("Accepted. Sound Turned Off.");
} else if (command.equals("Lights On")) {
Light = true;
EEPROM.update(112, 2);
Serial.println("Accepted. Sound Turned On.");
} else if (command.equals("Reset")) {
Serial.println("Are You Sure You Want To Reset ? ");
Serial.println("Type Confirm To Proceed Or Cancel To Cancel");
lastCommand = command;
} else if (command.equals("Cancel") && lastCommand.equals("Reset")) {
Serial.println("Good Choice");
lastCommand = command;
} else if (command.equals("TEST")) {
allfalse();
allon();
Serial.println("You Have 3 Seconds To Input Delay");
delay(3000);
alloff();
lastCommand = command;
} else if (command.equals("Notes")) {
Serial.println();
Serial.println("Need to fix game 2");
Serial.println("HELP Function Built");
Serial.println("Added lights on and off serial commands");
Serial.println("Added Developer Mode");
Serial.println("work to debug game 1");
Serial.println("debugged settings and replaced time with sensitivity");
lastCommand = command;
} else if (command.indexOf("indent") != -1 && developermode == true) {
char fifthCharacter = command.charAt(7);
Serial.println(fifthCharacter);
blankline(fifthCharacter);
} else if (command.equals("Confirm") && lastCommand.equals("Reset")) {
Serial.println("Reseting");
delay(150);
resetFunc();
} else if (command.equals("Direct Reset")) {
lcd.clear();
Serial.print("SAVING");
lcd.print("SAVING");
for (int i = 0; i < random(3, 15); i++) {
delay(300);
lcd.print(".");
Serial.print(".");
}
Serial.println();
delay(random(1, 500));
lcd.clear();
lcd.print("RESETING");
Serial.print("RESETING");
Serial.println();
Serial.println();
delay(400);
resetFunc();
} else if (command.equals("Activate Serial Feedback")) {
Serial.println("Serial Feedback Enabled");
Serial.println("Thank You");
serialconnected = true;
} else if (command.equals("confirm") && activategame1 == true) {
lcd.clear();
allfalse();
countdown = true;
} else if (command.equals("Version Notes")) {
Serial.println();
Serial.println("Need to fix game 2");
Serial.println("HELP Function Built");
Serial.println("Added lights on and off serial commands");
Serial.println("Added Developer Mode");
Serial.println("work to debug game 1");
Serial.println("debugged settings and replaced time with reset");
Serial.println("Added manual reset option");
Serial.println();
Serial.println("Version 1.2.1");
Serial.println();
} else if (command.equals("Bool Check") && developermode == true) {
Serial.println();
Serial.println("Active Booleans");
if (developermode == true) {
Serial.println("developermode");
}
if (backS == true) {
Serial.println("backS");
}
if (SaveS == true) {
Serial.println("SaveS");
}
if (G3T == true) {
Serial.println("G3T");
}
if (G2T == true) {
Serial.println("G2T");
}
if (G1T == true) {
Serial.println("G1T");
}
if (TIME == true) {
Serial.println("TIME");
}
if (confirmreset == true) {
Serial.println("confirmreset");
}
if (game2s == true) {
Serial.println("game2s");
}
if (game2over == true) {
Serial.println("game2over");
}
if (LIGHTS == true) {
Serial.println("LIGHTS");
}
if (SOUND == true) {
Serial.println("SOUND");
}
if (G1HS == true) {
Serial.println("G1HS");
}
if (G2HS == true) {
Serial.println("G2HS");
}
if (G3HS == true) {
Serial.println("G3HS");
}
if (backRR == true) {
Serial.println("backRR");
}
if (SaveRR == true) {
Serial.println("SaveRR");
}
if (bool4 == true) {
Serial.println("bool4");
}
if (newscore == true) {
Serial.println("newscore");
}
if (refreshnow == true) {
Serial.println("refreshnow");
}
if (gameselection == true) {
Serial.println("gameselection");
}
if (repeatonce == true) {
Serial.println("repeatonce");
}
if (gameover == true) {
Serial.println("gameover");
}
if (gaming == true) {
Serial.println("gaming");
}
if (clicked == true) {
Serial.println("clicked");
}
if (countdown == true) {
Serial.println("countdown");
}
if (proceedgame1 == true) {
Serial.println("proceedgame1");
}
if (putina0 == true) {
Serial.println("putina0");
}
if (first == true) {
Serial.println("first");
}
if (game1 == true) {
Serial.println("game1");
}
if (game2 == true) {
Serial.println("game2");
}
if (game3 == true) {
Serial.println("game3");
}
if (notimer == true) {
Serial.println("notimer");
}
if (timer == true) {
Serial.println("timer");
}
if (settings == true) {
Serial.println("settings");
}
if (refreshchange == true) {
Serial.println("refreshchange");
}
if (highscores == true) {
Serial.println("highscores");
}
if (gamesorsettings == true) {
Serial.println("gamesorsettings");
}
if (activategame1 == true) {
Serial.println("activategame1");
}
if (activategame2 == true) {
Serial.println("activategame2");
}
if (activategame3 == true) {
Serial.println("activategame3");
}
if (startup == true) {
Serial.println("startup");
}
if (repeatonce == true) {
Serial.println("repeatonce");
}
if (gameover == true) {
Serial.println("gameover");
}
if (gaming == true) {
Serial.println("gaming");
}
if (clicked == true) {
Serial.println("clicked");
}
if (countdown == true) {
Serial.println("countdown");
}
if (putina0 == true) {
Serial.println("putina0");
}
if (game1 == true) {
Serial.println("game1");
}
if (game2 == true) {
Serial.println("game2");
}
if (game3 == true) {
Serial.println("game3");
}
if (notimer == true) {
Serial.println("notimer");
}
if (timer == true) {
Serial.println("timer");
}
if (settings == true) {
Serial.println("settings");
}
if (refreshchange == true) {
Serial.println("refreshchange");
}
if (highscores == true) {
Serial.println("highscores");
}
if (gamesorsettings == true) {
Serial.println("gamesorsettings");
}
if (activategame1 == true) {
Serial.println("activategame1");
}
if (activategame2 == true) {
Serial.println("activategame2");
}
if (activategame3 == true) {
Serial.println("activategame3");
}
Serial.println();
Serial.println();
} else if (command.equals("Sensor Check") || command.equals("Sensor States")) {
sensorcheck();
Serial.println();
if (joy2Bs == LOW) {
Serial.println("Joystick 2 Button");
}
if (touch1s == HIGH) {
Serial.println("Touch 1");
}
if (touch2s == HIGH) {
Serial.println("Touch 2");
}
if (touch3s == HIGH) {
Serial.println("Touch 3");
}
if (joy1Bs == LOW) {
Serial.println("Joystick 1 Button");
}
if (twisters == LOW) {
Serial.println("Twister Pressed");
}
if (redBs == LOW) {
Serial.println("Red Button");
}
if (greenBs == LOW) {
Serial.println("Green Button");
}
if (yellowBs == LOW) {
Serial.println("Yellow Button");
}
if (flickers == LOW) {
Serial.println("Flicker");
}
if (rotary1s == LOW) {
Serial.println("Roatary 1");
}
if (rotary2s == LOW) {
Serial.println("Roatary 2");
}
Serial.println();
Serial.println("Joystick Values");
Serial.print("Joystick 1 X Value:");
Serial.println(joy1Xs);
Serial.print("Joystick 2 X Value:");
Serial.println(joy2Xs);
Serial.print("Joystick 1 Y Value:");
Serial.println(joy1Ys);
Serial.print("Joystick 2 Y Value:");
Serial.println(joy2Ys);
} else if (command.equals("Developer Mode") || command.equals("Developer Mode")) {
sentcommands();
Serial.println("Type 'Developer' Username On or Off To Enter or Exit Developer Mode");
} else if (command.equals("DeveloperReagan On") || command.equals("Developer Reagan On")) {
Serial.println();
Serial.println("Password?");
lastCommand = command; /////////////////////////////////////////////////////////////////////////////////////////////////////////////
} else if (command.equals("31.5x2=Awesome!") && (lastCommand.equals("Developer Reagan On") || lastCommand.equals("DeveloperReagan On"))) {
serialconnected = true;
developermode = true;
EEPROM.update(114, 1);
Serial.println("Accepted");
} else if (command != ("31.5x2=Awesome!") && lastCommand == ("Developer Reagan On")
&& developermode == false) {
Serial.print("Wrong Password, ");
Serial.print(triesleft);
Serial.println(" Remaining");
triesleft = triesleft - 1;
if (triesleft == 1) {
Serial.println("Last Try Before Lockout");
}
} else if (command.equals("Data Bank Mode On")) {
EEPROM.update(4, 0);
Serial.println("Reseting");
delay(400);
resetFunc();
} /*else if (){
}*/
else if (command.equals("Joystick Values")) {
Serial.println();
Serial.println("Joystick Values");
Serial.print("Joystick 1 X Value:");
Serial.println(joy1Xs);
Serial.print("Joystick 2 X Value:");
Serial.println(joy2Xs);
Serial.print("Joystick 1 Y Value:");
Serial.println(joy1Ys);
Serial.print("Joystick 2 Y Value:");
Serial.println(joy2Ys);
} else Unkown();
}
if (bank == true) {
if (command.equals(User1)) {
Serial.print("Accepted Username: ");
Serial.println(command);
Serial.print("Please Enter Password For ");
Serial.println(command);
lastcommand = command;
} else if (lastcommand == (User1) && command.equals(User1pass)) {
Serial.println("Correct");
} else if (lastcommand == (User1) && command != ("31.5x2=Awesome!") && ask == true) {
Serial.println("Incorect Password");
Serial.print(tries);
Serial.println(" Tries Left");
tries = tries - 1;
if (tries < 0) {
Lockdown = true;
fails = fails + 1;
if (fails == 1) {
t = 1;
EEPROM.write(3, 1);
}
if (fails == 2) {
t = 3;
EEPROM.write(3, 2);
}
if (fails == 3) {
t = 5;
EEPROM.write(3, 3);
}
if (fails == 4) {
t = 10;
EEPROM.write(3, 4);
}
if (fails == 5) {
t = 15;
EEPROM.write(3, 5);
}
if (fails == 6) {
t = 30;
EEPROM.write(3, 6);
}
if (fails == 7) {
t = 60;
EEPROM.write(3, 7);
}
left = 1;
ask = false;
EEPROM.write(1, 2);
EEPROM.write(2, 1);
Serial.print("Please Try Again In ");
Serial.print(t);
Serial.println(" Minute(s)");
lockoutend = currentTime + (t * 60000);
}
} else if (command.equals("Data Bank Mode Off")) {
EEPROM.update(4, 1);
Serial.println("Reseting");
delay(400);
resetFunc();
}
}
}
refreshcounter = refreshcounter + 1;
if (refreshcounter > 10 || command.equals("refresh")) {
refreshnow = true;
refreshcounter = 0;
}
}
void Unkown() {
Serial.print("Uknown Command '");
Serial.print(command);
Serial.println("'.");
Serial.println("Please Type Valid Command Or Change Letter Case");
Serial.println("Type 'HELP' For List Of Commands");
}
The code i believe is causing the problem is located lines 2363 - 2424, 2342 - 2347, 255 - 265, and 378 - 426. Thank you!