#include <LiquidCrystal.h>

#define PUSH 20

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
uint8_t c0[8]={0x00,0x0A,0x1F,0x1F,0x0E,0x04,0x00,0x00};
uint8_t c1[8]={0x00,0x00,0x0A,0x00,0x11,0x0E,0x00,0x00};
uint8_t c2[8]={0x07,0x17,0x16,0x1F,0x0E,0x02,0x03,0x00};
uint8_t c3[8]={0x07,0x17,0x16,0x1F,0x0E,0x08,0x0C,0x00};
uint8_t c4[8]={0x06,0x16,0x16,0x1E,0x1E,0x06,0x06,0x1F};
uint8_t c5[8]={0x00,0x0C,0x0D,0x0F,0x0C,0x0C,0x0C,0x1F};
uint8_t c6[8]={0x1D,0x1C,0x19,0x02,0x14,0x00,0x00,0x00};
uint8_t c7[8]={0x1C,0x1D,0x18,0x02,0x08,0x00,0x00,0x00};


void setup() {
  // put your setup code here, to run once:
  pinMode(PUSH, INPUT_PULLUP);
  lcd.begin(16, 2);

  lcd.createChar(0, c0);
  lcd.createChar(1, c1);
  lcd.createChar(2, c2);
  lcd.createChar(3, c3);
  lcd.createChar(4, c4);
  lcd.createChar(5, c5);
  lcd.createChar(6, c6);
  lcd.createChar(7, c7);
}

void loop() {
  // put your main code here, to run repeatedly:
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("PUSH");
  while(digitalRead(PUSH)==1);
  delay(100);
lcd.clear();

int cactus = 15;
int points = 0;

 while(1){
  if(digitalRead(PUSH)== 0){
    lcd.setCursor(2, 1);
    lcd.print("  ");
     lcd.setCursor(cactus, 1);
     lcd.write((byte)5);
     lcd.setCursor(2,0);
     lcd.write((byte)2);
     delay(200);
     lcd.setCursor(2, 0);
     lcd.write((byte)3);
     delay(200);
     lcd.setCursor(cactus, 1);
    lcd.print("  ");
     
     cactus -= 1;
    if(cactus < 0){
      cactus = 15;
    }
    if(cactus == 2){
      points += 1;
      lcd.home();
      lcd.print("Puntaje:");
      lcd.setCursor(12, 0);
      lcd.print(points);
    }
  }else{
    lcd.setCursor(2, 0);
    lcd.print("  ");
    lcd.setCursor(cactus, 1);
    lcd.write((byte)5);
    lcd.setCursor(2,1);
    lcd.write((byte)2);
    delay(200);
    lcd.setCursor(2, 1);
    lcd.write((byte)3);
    delay(200);
    lcd.setCursor(cactus, 1);
    lcd.print("  ");
    cactus -= 1;
    if(cactus < 0){
    cactus = 15;
    }
    if(cactus == 2){
      lcd.clear();
      lcd.setCursor(2, 1);
      lcd.write((byte)6);
      delay(500);
      lcd.clear();
      lcd.print("    Game Over");
      delay(2000);
      break;
    }
  }
  
  }
     
 }


BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT