#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
int diceButton = 10;
int reply;
int count = 0;
long diceOne;
long diceTwo;
void setup() {
lcd.begin(16, 2);
lcd.backlight();
pinMode(diceButton, INPUT);
randomSeed(analogRead(0));
lcd.setCursor(1, 0);
lcd.print("Roll the dice!");
}
void buildUp() {
lcd.clear();
int countDelay = 220;
int setColumn = 0;
for (count = 0; count <= 16; count++) {
lcd.setCursor(setColumn, 0);
lcd.print(random(1, 7));
lcd.setCursor(setColumn, 1);
lcd.print(random(1, 7));
delay(countDelay);
countDelay -= 13;
setColumn += 1;
}
}
void loop() {
diceButton = digitalRead(10);
diceOne = random(1, 7);
diceTwo = random(1, 7);
if (diceButton == HIGH) {
buildUp();
lcd.clear();
lcd.setCursor(7, 0);
lcd.print(diceOne);
lcd.setCursor(7, 1);
lcd.print(diceTwo);
if (diceOne + diceTwo == 7) {
lcd.clear();
lcd.setCursor(7, 0);
lcd.print("7");
lcd.setCursor(3, 1);
lcd.print("The Robber");
}
}
}