#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// The LCD display you have is I2C with 4 wires
// Connect Vcc, 0V as normal - SCL and SDA as per device - on UNO:
// SCL - pin A5
// SDA - pin A4
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
//define pins for two push buttons for each goal
#define goalHome 3
#define goalAway 2
// setup two int variables to hold each score
int scoreHome = 0;
int scoreAway = 0;
void setup()
{
//setup two input pins wuth pull-up resistors
pinMode(goalHome, INPUT_PULLUP);
pinMode(goalAway, INPUT_PULLUP);
// initialize the lcd
lcd.init();
// Backlight on
lcd.backlight();
//Print top line to the LCD
lcd.setCursor(0,0);
lcd.print("HOME - AWAY");
}
void loop()
{
//Add one to the home team's score
if(digitalRead(goalHome)==LOW){
scoreHome++;
delay(500);
}
//Add one to the away team's score
if(digitalRead(goalAway)==LOW){
scoreAway++;
delay(500);
}
//write the new scors on to the second line in the right place
lcd.setCursor(0,1);
lcd.print(scoreHome);
lcd.setCursor(9,1);
lcd.print(scoreAway);
}