#include <LiquidCrystal.h>
const int buttonPin = 8;
int buttonState = 0;
int lastButtonState = LOW; // Assume button starts unpressed (PULLUP)
unsigned long lastTapTime = 0;
int tapCount = 0;
bool flag = true;
double moneyCount = 50;
LiquidCrystal lcdOne(22, 23, 4, 5, 6, 7);
LiquidCrystal lcdTwo(24, 25, 10, 11, 12, 13);
LiquidCrystal lcdThree(14, 15, 16, 17, 18, 19);
void setup() {
Serial.begin(9600);
Serial.print("£"); // Try direct symbol (works in some IDEs)
Serial.println(moneyCount);
randomSeed(analogRead(A0));
pinMode(buttonPin, INPUT); // Button to GND
lcdOne.begin(16, 2);
lcdTwo.begin(16, 2);
lcdThree.begin(16, 2);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && flag && tapCount != 7) {
singleClick();
flag = false;
}
// Detect button press (LOW due to PULLUP)
if (buttonState == LOW && lastButtonState == HIGH) {
// Check if taps are within 0.85s of each other
if (millis() - lastTapTime < 850) {
tapCount++;
} else {
tapCount = 1; // Reset if too slow
}
lastTapTime = millis(); // Update last tap time
}
// If 7 taps are registered, show "7" after 0.85s delay
if (tapCount == 7 && millis() - lastTapTime >= 850) {
showSeven();
tapCount = 0; // Reset counter
}
lastButtonState = buttonState;
}
void showSeven() {
lcdOne.clear();
lcdOne.print("7");
lcdTwo.clear();
lcdTwo.print("7");
lcdThree.clear();
lcdThree.print("7");
delay(2000); // Display for 2 seconds
lcdOne.clear();
lcdTwo.clear();
lcdThree.clear();
}
void singleClick(){
moneyCount = moneyCount - 1;
Serial.print("£"); // Try direct symbol (works in some IDEs)
Serial.println(moneyCount);
int randomNumOne = random(0, 5);
int randomNumTwo = random(0, 5); // Generates a number between 0-999
int randomNumThree = random(0, 5); // Generates a number between 0-999
lcdOne.clear();
lcdOne.setCursor(0, 1); // Move to 2nd line
lcdOne.print(randomNumOne);
lcdTwo.clear();
lcdTwo.setCursor(0, 1);
lcdTwo.print(randomNumTwo);
lcdThree.clear();
lcdThree.setCursor(0, 1);
lcdThree.print(randomNumThree);
}