#include <LiquidCrystal_I2C.h>
#define push 6
LiquidCrystal_I2C lcd(0x27, 16, 2);
int push1 = 0;
int lastPushStatus = 0;
uint8_t dino[8] = {
0b00110,
0b00111,
0b00101,
0b10110,
0b11110,
0b11110,
0b01010,
0b00010,
};
uint8_t dino1[8] = {
0b00110,
0b00111,
0b00101,
0b10110,
0b11110,
0b11110,
0b01010,
0b01000,
};
uint8_t cact[8] = {
0b00100,
0b00100,
0b00100,
0b10101,
0b11111,
0b00100,
0b00100,
0b00100,
};
uint8_t tero[8] = {
0b00000,
0b00100,
0b01100,
0b01110,
0b11111,
0b01100,
0b00100,
0b00000,
};
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
lcd.createChar(3, dino);
lcd.setCursor(2, 1);
lcd.createChar(2, dino1);
lcd.setCursor(2, 1);
pinMode(push, INPUT_PULLUP);
delay(300);
}
void loop() {
while(digitalRead(push) == 1){
lcd.clear();
lcd.setCursor(1,0);
lcd.print("Press To Start");
delay(400);
lcd.clear();
delay(400);
}
int tiempo = 1;
int i = 15;
int j = 25;
while(1){
if(digitalRead(push) == 1){
lcd.setCursor(2, 0);
lcd.print(" ");
lcd.setCursor(2, 1);
lcd.write(3);
lcd.setCursor(i, 1);
lcd.write(5);
lcd.createChar(5, cact);
lcd.setCursor(j, 0);
lcd.write(4);
lcd.createChar(4, tero);
delay(50);
lcd.setCursor(2, 1);
lcd.write(2);
lcd.setCursor(i, 1);
lcd.print(" ");
lcd.setCursor(j, 0);
lcd.print(" ");
delay(50);
i --;
if(i < 0){
i = 15;
}
j --;
if(j < 0){
j = 11;
}
}
else{
lcd.setCursor(2, 1);
lcd.print(" ");
lcd.setCursor(2, 0);
lcd.write(3);
lcd.setCursor(i, 1);
lcd.write(5);
lcd.createChar(5, cact);
lcd.setCursor(j, 0);
lcd.write(4);
lcd.createChar(4, tero);
delay(50);
lcd.setCursor(2, 0);
lcd.write(2);
lcd.setCursor(i, 1);
lcd.print(" ");
lcd.setCursor(j, 0);
lcd.print(" ");
delay(50);
i -= 1;
if(i < 0){
i = 15;
}
j -= 1;
if(j < 0){
j = 11;
}
}
delay(10);
if(digitalRead(push) == 1 && i == 2){
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Game Over");
delay(2500);
lcd.clear();
loop();
}
if(digitalRead(push) == 0 && j == 2){
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Game Over");
delay(2500);
lcd.clear();
loop();
}
if(i == 2){
lcd.setCursor(14,0);
lcd.print(tiempo);
tiempo++;
}
if(j == 2){
lcd.setCursor(14,0);
lcd.print(tiempo);
tiempo++;
}
}
delay(1); // this speeds up the simulation
}
/*for (i = 16; i >= 0; i--) {
lcd.setCursor(i, 1);
lcd.write(5);
lcd.createChar(5, cact);
delay(100);
lcd.setCursor(i, 1);
lcd.print(" ");*/