#ifdef __AVR__
#include <avr/power.h>
#endif
long randNumber;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
boolean oldSwitchState = LOW;
boolean newSwitchState = LOW;
byte state = 0;
void setup() {
lcd.init();
lcd.backlight();
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
}
int value = -1;
void loop()
{
lcd.setCursor(0, 0);
lcd.print("Work Together To");
lcd.setCursor(0, 1);
lcd.print("Match The Number To");
lcd.setCursor(0, 2);
lcd.print("Get All 4 Codes");
//randomSeed(analogRead(0));
//randNumber = random(100, 255-1);
if (state > 3) {
state = 0;
}
if (state == 0)
{
lcd.setCursor(11, 3);
lcd.print("254 =");
if (PIND != value)
{
lcd.setCursor(17, 3);
lcd.print(PIND);
lcd.print(" ");
value = PIND;
}
if (PIND == 254)
{
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Box 1 Code: 1234");
lcd.setCursor(4, 2);
lcd.print("Code 1 Of 4");
lcd.setCursor(0, 3);
lcd.print("You Must Get All 4!");
delay(5000);
lcd.clear();
state++;
}
}
if (state == 1)
{
lcd.setCursor(11, 3);
lcd.print("127 =");
if (PIND != value)
{
lcd.setCursor(17, 3);
lcd.print(PIND);
lcd.print(" ");
value = PIND;
}
if (PIND == 127)
{
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Box 2 Code: 5678");
lcd.setCursor(4, 2);
lcd.print("Code 2 Of 4");
lcd.setCursor(0, 3);
lcd.print("You Must Get All 4!");
delay(5000);
lcd.clear();
state++;
}
}
if (state == 2)
{
lcd.setCursor(11, 3);
lcd.print("191 =");
if (PIND != value)
{
lcd.setCursor(17, 3);
lcd.print(PIND);
lcd.print(" ");
value = PIND;
}
if (PIND == 191)
{
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Box 3 Code: 9012");
lcd.setCursor(4, 2);
lcd.print("Code 3 Of 4");
lcd.setCursor(0, 3);
lcd.print("You Must Get All 4!");
delay(5000);
lcd.clear();
state++;
}
}
if (state == 3)
{
lcd.setCursor(11, 3);
lcd.print("223 =");
if (PIND != value)
{
lcd.setCursor(17, 3);
lcd.print(PIND);
lcd.print(" ");
value = PIND;
}
if (PIND == 223)
{
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Box 4 Code: 3456");
lcd.setCursor(4, 2);
lcd.print("Code 4 Of 4");
lcd.setCursor(0, 3);
lcd.print("You Must Get All 4!");
delay(5000);
lcd.clear();
state++;
}
}
}