#include <LiquidCrystal.h>
// Symbol class to manage custom characters
class Symbol {
public:
String name;
int nameSize;
int symbolId;
byte* characterBytes[8]; // Array of pointers to hold up to 8 byte arrays
int bytesCount; // Number of byte arrays for this symbol
// Positions for each character (x, y coordinates)
struct Position {
int x;
int y;
};
Position positions[8];
// Constructor
Symbol(String symbolName, int id, byte* bytes[], int numBytes) {
name = symbolName;
nameSize = symbolName.length();
symbolId = id;
bytesCount = numBytes;
// Copy the byte array pointers
for (int i = 0; i < numBytes && i < 8; i++) {
characterBytes[i] = bytes[i];
}
}
// Set position for each character
void setPosition(int index, int x, int y) {
if (index >= 0 && index < bytesCount) {
positions[index].x = x;
positions[index].y = y;
}
}
// Register and place on LCD
void placeOnLCD(LiquidCrystal& lcd) {
for (int i = 0; i < bytesCount; i++) {
lcd.createChar(symbolId + i, characterBytes[i]);
lcd.setCursor(positions[i].x, positions[i].y);
lcd.write(symbolId + i);
}
}
};
// Class to manage an individual LCD display
class SlotDisplay {
private:
LiquidCrystal* lcd;
bool isCorrect;
bool isLocked;
int targetSymbol;
int currentSymbol;
Symbol* symbols[5]; // Array to hold Cherry, Currency, Diamond, Bar, Seven symbols
public:
SlotDisplay(LiquidCrystal* lcdObj, int target) {
lcd = lcdObj;
isCorrect = false;
isLocked = false;
targetSymbol = target;
currentSymbol = -1;
}
void setTargetSymbol(int target) {
targetSymbol = target;
}
void setSymbols(Symbol* cherry, Symbol* currency, Symbol* diamond, Symbol* bar, Symbol* seven) {
symbols[0] = cherry;
symbols[1] = currency;
symbols[2] = diamond;
symbols[3] = bar;
symbols[4] = seven;
}
void display(int symbolIndex) {
// If the display is locked, don't change it
if (isLocked) return;
currentSymbol = symbolIndex;
lcd->clear();
if (symbolIndex >= 0 && symbolIndex <= 4) {
symbols[symbolIndex]->placeOnLCD(*lcd);
} else {
lcd->setCursor(0, 1);
lcd->print(symbolIndex);
}
// Check if this is the target symbol
isCorrect = (symbolIndex == targetSymbol);
}
// Method to display a custom symbol directly
void displayCustomSymbol(byte* bytes[], int numBytes, int positions[][2]) {
lcd->clear();
for (int i = 0; i < numBytes; i++) {
lcd->createChar(i, bytes[i]);
lcd->setCursor(positions[i][0], positions[i][1]);
lcd->write(i);
}
}
// Method to lock in the current symbol
void lockSymbol() {
if (currentSymbol == targetSymbol) {
isLocked = true;
isCorrect = true;
}
}
// Method to forcibly lock any symbol (used for cheat)
void forceLock() {
isLocked = true;
isCorrect = (currentSymbol == targetSymbol);
}
bool isDisplayCorrect() {
return isCorrect;
}
bool isDisplayLocked() {
return isLocked;
}
int getCurrentSymbol() {
return currentSymbol;
}
int getTargetSymbol() {
return targetSymbol;
}
void reset() {
lcd->clear();
isCorrect = false;
isLocked = false;
currentSymbol = -1;
}
void unlock() {
isLocked = false;
}
LiquidCrystal* getLCD() {
return lcd;
}
};
// Main game class
class SlotMachine {
private:
SlotDisplay* displays[3];
const int buttonPin;
int buttonState;
int lastButtonState;
unsigned long lastTapTime;
int tapCount;
bool flag;
double moneyCount;
bool roundComplete;
int currentRound;
int targetSequences[5][3]; // 5 rounds, 3 positions each
Symbol* cherrySymbol;
Symbol* currencySymbol;
Symbol* diamondSymbol;
Symbol* barSymbol;
Symbol* sevenSymbol;
bool gameComplete;
// New variables for auto-start and message display
unsigned long roundCompleteTime;
bool showingRoundMessage;
bool showingWinMessage;
unsigned long messageStartTime;
public:
// bool isGameComplete() {
// return gameComplete;
// }
SlotMachine(int button, LiquidCrystal* lcd1, LiquidCrystal* lcd2, LiquidCrystal* lcd3)
: buttonPin(button) {
// Initialize variables
buttonState = LOW;
lastButtonState = LOW;
lastTapTime = 0;
tapCount = 0;
flag = true;
moneyCount = 50;
roundComplete = false;
currentRound = 0;
gameComplete = false;
// New variables initialization
roundCompleteTime = 0;
showingRoundMessage = false;
showingWinMessage = false;
messageStartTime = 0;
// Set up target sequences for each round
// Round 0: Cherry (0,0,0)
targetSequences[0][0] = 0;
targetSequences[0][1] = 0;
targetSequences[0][2] = 0;
// Round 1: Currency (1,1,1)
targetSequences[1][0] = 1;
targetSequences[1][1] = 1;
targetSequences[1][2] = 1;
// Round 2: Diamond (2,2,2)
targetSequences[2][0] = 2;
targetSequences[2][1] = 2;
targetSequences[2][2] = 2;
// Round 3: Bar (3,3,3)
targetSequences[3][0] = 3;
targetSequences[3][1] = 3;
targetSequences[3][2] = 3;
// Round 4: Seven (4,4,4)
targetSequences[4][0] = 4;
targetSequences[4][1] = 4;
targetSequences[4][2] = 4;
// Initialize displays with the first round target
displays[0] = new SlotDisplay(lcd1, targetSequences[0][0]);
displays[1] = new SlotDisplay(lcd2, targetSequences[0][1]);
displays[2] = new SlotDisplay(lcd3, targetSequences[0][2]);
// Setup symbols
setupSymbols();
// Assign symbols to displays
for (int i = 0; i < 3; i++) {
displays[i]->setSymbols(cherrySymbol, currencySymbol, diamondSymbol, barSymbol, sevenSymbol);
}
// Setup pin mode
pinMode(buttonPin, INPUT);
// Display round message at the start
showRoundMessage();
// Display current round information
Serial.print("Round ");
Serial.print(currentRound + 1);
Serial.print(" - Target: ");
Serial.println(getSymbolName(targetSequences[currentRound][0]));
}
String getSymbolName(int symbolId) {
switch(symbolId) {
case 0: return "Cherry";
case 1: return "Currency";
case 2: return "Diamond";
case 3: return "Bar";
case 4: return "Seven";
default: return "Unknown";
}
}
void setupSymbols() {
// Cherry symbol setup
static byte cherry1x8[] = { B00010, B00100, B01000, B10000, B00000, B00000, B00000, B0000 };
static byte cherry0x6[] = { B00000, B00000, B00001, B00011, B00011, B00010, B00011, B00001 };
static byte cherry0x7[] = { B00000, B11100, B11110, B11111, B11111, B11111, B00110, B11100 };
static byte cherry0x8[] = { B00000, B00000, B00000, B00000, B10000, B01000, B00100, B00011 };
static byte cherry1x6[] = { B00001, B00011, B00011, B00010, B00011, B00001, B00000, B00000 };
static byte cherry1x7[] = { B11100, B11110, B11111, B11111, B00111, B11110, B11100, B00000 };
static byte cherry1x9[] = { B10000, B01000, B01000, B00000, B00000, B00000, B00000, B00000 };
byte* cherryBytes[] = {
cherry0x6, cherry0x7, cherry0x8, cherry1x6, cherry1x7, cherry1x8, cherry1x9
};
cherrySymbol = new Symbol("Cherry", 0, cherryBytes, 7);
cherrySymbol->setPosition(0, 6, 0); // cherry0x6
cherrySymbol->setPosition(1, 7, 0); // cherry0x7
cherrySymbol->setPosition(2, 8, 0); // cherry0x8
cherrySymbol->setPosition(3, 6, 1); // cherry1x6
cherrySymbol->setPosition(4, 7, 1); // cherry1x7
cherrySymbol->setPosition(5, 8, 1); // cherry1x8
cherrySymbol->setPosition(6, 9, 1); // cherry1x9
// Currency symbol setup
static byte currency1x8[] = { B01100, B11111, B01100, B01100, B01100, B11100, B11000, B00000 };
static byte currency0x6[] = { B00000, B00110, B01110, B01100, B01100, B01100, B11111, B01100 };
static byte currency0x7[] = { B00000, B00011, B00111, B01100, B01100, B01100, B11111, B01100 };
static byte currency0x8[] = { B00000, B10000, B11000, B01100, B01100, B01100, B11111, B01100 };
static byte currency1x6[] = { B01100, B11111, B01100, B01100, B01100, B00111, B00011, B00000 };
static byte currency1x7[] = { B01100, B11111, B01100, B01100, B01100, B11000, B10000, B00000 };
byte* currencyBytes[] = {
currency0x6, currency0x7, currency0x8, currency1x6, currency1x7, currency1x8
};
currencySymbol = new Symbol("Currency", 1, currencyBytes, 6);
currencySymbol->setPosition(0, 6, 0); // currency0x6
currencySymbol->setPosition(1, 7, 0); // currency0x7
currencySymbol->setPosition(2, 8, 0); // currency0x8
currencySymbol->setPosition(3, 6, 1); // currency1x6
currencySymbol->setPosition(4, 7, 1); // currency1x7
currencySymbol->setPosition(5, 8, 1); // currency1x8
// Diamond symbol setup
static byte diamond0x8[] = { B00000, B10000, B11100, B01100, B00110, B10010, B11110, B11110 };
static byte diamond0x6[] = { B00000, B00000, B00000, B00000, B00000, B00011, B00011, B01111 };
static byte diamond0x7[] = { B00000, B00111, B00100, B11111, B11111, B11111, B11111, B11111 };
static byte diamond1x6[] = { B01111, B00011, B00011, B00000, B00000, B00000, B00000, B00000 };
static byte diamond1x7[] = { B11111, B11111, B11111, B11111, B11111, B00111, B00111, B00000 };
static byte diamond1x8[] = { B11110, B11110, B11110, B11110, B11100, B11100, B10000, B00000 };
byte* diamondBytes[] = {
diamond0x8, diamond0x6, diamond0x7, diamond1x6, diamond1x7, diamond1x8
};
diamondSymbol = new Symbol("Diamond", 2, diamondBytes, 6);
diamondSymbol->setPosition(0, 8, 0); // diamond0x7
diamondSymbol->setPosition(1, 6, 0); // diamond0x8
diamondSymbol->setPosition(2, 7, 0); // diamond0x9
diamondSymbol->setPosition(3, 6, 1); // diamond1x7
diamondSymbol->setPosition(4, 7, 1); // diamond1x8
diamondSymbol->setPosition(5, 8, 1); // diamond1x9
// Bar symbol setup
static byte bar1x8[] = { B10001, B11110, B00000, B00000, B11111, B10001, B10001, B01110 };
static byte bar0x7[] = { B11111, B10000, B10000, B11111, B00000, B00000, B11111, B00000 };
static byte bar0x8[] = { B11111, B10001, B10001, B01111, B00000, B00000, B11110, B10001 };
static byte bar1x7[] = { B00000, B11111, B00000, B00000, B11111, B00000, B00000, B11111 };
byte* barBytes[] = {
bar0x7, bar0x8, bar1x7, bar1x8
};
barSymbol = new Symbol("Bar", 3, barBytes, 4);
barSymbol->setPosition(0, 7, 0); // bar0x7
barSymbol->setPosition(1, 8, 0); // bar0x8
barSymbol->setPosition(2, 7, 1); // bar1x7
barSymbol->setPosition(3, 8, 1); // bar1x8
// Seven symbol setup
static byte seven0x6[] = { B00000, B00000, B00000, B00000, B10000, B11111, B11111, B11111 };
static byte seven0x7[] = { B00000, B00011, B00011, B00001, B00001, B00001, B11001, B11111 };
static byte seven0x8[] = { B00000, B11111, B11111, B11110, B11110, B11110, B11110, B11110 };
static byte seven1x6[] = { B11111, B11111, B11111, B10000, B00000, B00000, B00000, B00000 };
static byte seven1x7[] = { B11111, B11111, B11111, B11111, B00111, B00001, B00000, B00000 };
static byte seven1x8[] = { B11110, B11110, B11110, B11111, B11111, B11111, B01111, B00000 };
byte* sevenBytes[] = {
seven0x6, seven0x7, seven0x8, seven1x6, seven1x7, seven1x8
};
sevenSymbol = new Symbol("Seven", 4, sevenBytes, 6);
sevenSymbol->setPosition(0, 6, 0); // seven0x6
sevenSymbol->setPosition(1, 7, 0); // seven0x7
sevenSymbol->setPosition(2, 8, 0); // seven0x8
sevenSymbol->setPosition(3, 6, 1); // seven1x6
sevenSymbol->setPosition(4, 7, 1); // seven1x7
sevenSymbol->setPosition(5, 8, 1); // seven1x8
}
void showWinMessage() {
for (int i = 0; i < 3; i++) {
displays[i]->getLCD()->clear();
}
//y
static byte y_0x6[] = { B00000, B00000, B11111, B11111, B10000, B10000, B10000, B10000 };
static byte y_1x8[] = { B00000, B00000, B11000, B00110, B00001, B00000, B00000, B00000 };
static byte y_0x7[] = { B00000, B00000, B00000, B00000, B00000, B00000, B00000, B00011 };
static byte y_0x8[] = { B00000, B00000, B00000, B00000, B00001, B00110, B11000, B00000 };
static byte y_1x6[] = { B11111, B00000, B00000, B00000, B00000, B00000, B00000, B00000 };
static byte y_1x7[] = { B11100, B00011, B00000, B00000, B00000, B00000, B00000, B00000 };
byte* y_Bytes[] = { y_0x6, y_0x7, y_0x8, y_1x6, y_1x7, y_1x8 };
int y_Positions[6][2] = { {6,0}, {7, 0}, {8, 0}, {6,1}, {7, 1}, {8, 1} };
//o
static byte o_0x6[] = { B00000, B00000, B11111, B11111, B10000, B10000, B10000, B10000 };
static byte o_0x7[] = { B00000, B00000, B11111, B11111, B00000, B00000, B00000, B00000 };
static byte o_0x8[] = { B00000, B00000, B11111, B11111, B00001, B00001, B00001, B00001 };
static byte o_1x6[] = { B10000, B10000, B10000, B10000, B11111, B00000, B00000, B00000 };
static byte o_1x7[] = { B00000, B00000, B00000, B00000, B11111, B00000, B00000, B00000 };
static byte o_1x8[] = { B00001, B00001, B00001, B00001, B11111, B00000, B00000, B00000 };
byte* o_Bytes[] = { o_0x6, o_0x7, o_0x8, o_1x6, o_1x7, o_1x8 };
int o_Positions[6][2] = { {6,0}, {7,0}, {8,0}, {6,1}, {7,1}, {8,1} };
//u
static byte u_0x6[] = { B00000, B00000, B11111, B11111, B10000, B10000, B10000, B10000 };
static byte u_0x7[] = { B00000, B00000, B11111, B11111, B00000, B00000, B00000, B00000 };
static byte u_0x8[] = { B00000, B00000, B11111, B11111, B00000, B00000, B00000, B00000 };
static byte u_1x6[] = { B10000, B10000, B10000, B10000, B11111, B00000, B00000, B00000 };
static byte u_1x7[] = { B00000, B00000, B00000, B00000, B11111, B00000, B00000, B00000 };
static byte u_1x8[] = { B00000, B00000, B00000, B00000, B11111, B00000, B00000, B00000 };
byte* u_Bytes[] = { u_0x6, u_0x7, u_0x8, u_1x6, u_1x7, u_1x8 };
int u_Positions[6][2] = { {6,0}, {7,0}, {8,0}, {6,1}, {7,1}, {8,1} };
// Display characters on each LCD
for (int i = 0; i < 6; i++) {
displays[0]->getLCD()->createChar(i, y_Bytes[i]);
displays[0]->getLCD()->setCursor(y_Positions[i][0], y_Positions[i][1]);
displays[0]->getLCD()->write(i);
displays[1]->getLCD()->createChar(i, u_Bytes[i]);
displays[1]->getLCD()->setCursor(u_Positions[i][0], u_Positions[i][1]);
displays[1]->getLCD()->write(i);
displays[2]->getLCD()->createChar(i, o_Bytes[i]);
displays[2]->getLCD()->setCursor(o_Positions[i][0], o_Positions[i][1]);
displays[2]->getLCD()->write(i);
}
// Set message start time
messageStartTime = millis();
showingWinMessage = true;
}
// Show "TO WIN GET" message on the LCDs
void showRoundMessage() {
// Clear all displays
for (int i = 0; i < 3; i++) {
displays[i]->getLCD()->clear();
}
// TO - First LCD
static byte to_name1x7[] = { B11111, B11111, B11000, B11000, B11000, B11000, B11111, B11111 };
static byte to_name0x7[] = { B00000, B00000, B00000, B11111, B11111, B00000, B00000, B00000 };
static byte to_name0x8[] = { B00011, B00011, B00011, B11111, B11111, B00011, B00011, B00011 };
static byte to_name1x8[] = { B11111, B11111, B00011, B00011, B00011, B00011, B11111, B11111 };
byte* toBytes[] = { to_name0x7, to_name0x8, to_name1x7, to_name1x8 };
int toPositions[4][2] = { {7, 0}, {8, 0}, {7, 1}, {8, 1} };
// WIN - Second LCD
static byte win_name1x7[] = { B11111, B00001, B00000, B11111, B00011, B11100, B00000, B11111 };
static byte win_name0x6[] = { B11111, B10000, B11111, B10000, B11111, B00000, B10000, B11111 };
static byte win_name0x7[] = { B11111, B00000, B11111, B00000, B11111, B00000, B00001, B11111 };
static byte win_name1x6[] = { B11111, B10000, B00000, B11111, B00000, B00111, B11000, B11111 };
byte* winBytes[] = { win_name0x6, win_name0x7, win_name1x6, win_name1x7 };
int winPositions[4][2] = { {7, 0}, {8, 0}, {7, 1}, {8, 1} };
// GET - Third LCD
static byte get_name0x7[] = { B11111, B11111, B10000, B10001, B11111, B00001, B00000, B11111 };
static byte get_name0x8[] = { B11111, B11111, B00001, B00001, B00001, B00000, B00000, B11111 };
static byte get_name1x7[] = { B10000, B10000, B00000, B00000, B00000, B11111, B00000, B00000 };
static byte get_name1x8[] = { B10001, B10001, B00000, B00001, B00001, B11111, B00001, B00001 };
byte* getBytes[] = { get_name0x7, get_name0x8, get_name1x7, get_name1x8 };
int getPositions[4][2] = { {7, 0}, {8, 0}, {7, 1}, {8, 1} };
// Display characters on each LCD
for (int i = 0; i < 4; i++) {
displays[0]->getLCD()->createChar(i, toBytes[i]);
displays[0]->getLCD()->setCursor(toPositions[i][0], toPositions[i][1]);
displays[0]->getLCD()->write(i);
displays[1]->getLCD()->createChar(i, winBytes[i]);
displays[1]->getLCD()->setCursor(winPositions[i][0], winPositions[i][1]);
displays[1]->getLCD()->write(i);
displays[2]->getLCD()->createChar(i, getBytes[i]);
displays[2]->getLCD()->setCursor(getPositions[i][0], getPositions[i][1]);
displays[2]->getLCD()->write(i);
}
// Set message start time
messageStartTime = millis();
showingRoundMessage = true;
}
void update() {
if (gameComplete) return;
// Handle showing round message and then target symbol
if (showingRoundMessage) {
// Check if 2 seconds have passed since showing the message
if (millis() - messageStartTime >= 2000) {
showingRoundMessage = false;
// Show target symbols for the current round
for (int i = 0; i < 3; i++) {
displays[i]->display(targetSequences[currentRound][i]);
}
}
return; // Don't process further while showing the message
}
// Auto-advance to next round after a delay
if (roundComplete && millis() - roundCompleteTime >= 3000) {
advanceToNextRound();
return;
}
buttonState = digitalRead(buttonPin);
// Handle single click (pull the slot)
if (buttonState == HIGH && flag == true) {
// Regular spin
singleClick();
delay(50);
flag = false;
}
if (buttonState == LOW) {
flag = true;
delay(50);
}
// Handle rapid tapping (cheat code) - only if not in a completed round state
if (!roundComplete && 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
}
// Check for cheat code activation - only if not in a completed round state
if (!roundComplete) {
if (tapCount == 6 && millis() - lastTapTime >= 850) {
activateSymbolOnAll(0); // Cherry
tapCount = 0;
} else if (tapCount == 8 && millis() - lastTapTime >= 850) {
activateSymbolOnAll(1); // Currency
tapCount = 0;
} else if (tapCount == 7 && millis() - lastTapTime >= 850) {
activateSymbolOnAll(2); // Diamond
tapCount = 0;
} else if (tapCount == 3 && millis() - lastTapTime >= 850) {
activateSymbolOnAll(3); // Bar
tapCount = 0;
} else if (tapCount == 5 && millis() - lastTapTime >= 850) {
activateSymbolOnAll(4); // Seven
tapCount = 0;
}
}
lastButtonState = buttonState;
}
void singleClick() {
moneyCount = moneyCount - 1;
Serial.print("£");
Serial.println(moneyCount);
// Generate random numbers for each display
for (int i = 0; i < 3; i++) {
if (!displays[i]->isDisplayLocked()) {
int randomSymbol = random(0, 5); // Includes all 5 symbols (0-4)
displays[i]->display(randomSymbol);
}
}
// Check if we've won by getting matching symbols
checkForRandomWin();
}
// Advance to the next round
void advanceToNextRound() {
// Only advance if a round was completed
if (!roundComplete) return;
currentRound++;
roundComplete = false;
// Check if game is complete
if (currentRound >= 5) {
Serial.println("GAME COMPLETE! All rounds finished!");
showWinMessage();
gameComplete = true;
return;
}
// Reset displays for next round and update target symbols
for (int i = 0; i < 3; i++) {
displays[i]->reset();
displays[i]->setTargetSymbol(targetSequences[currentRound][i]);
}
// Show round message before showing target symbols
showRoundMessage();
// Show next round info
Serial.print("Round ");
Serial.print(currentRound + 1);
Serial.print(" - Target: ");
Serial.println(getSymbolName(targetSequences[currentRound][0]));
}
// Activate a specific symbol on all LCDs
void activateSymbolOnAll(int symbolId) {
// Display the symbol on all LCDs
for (int i = 0; i < 3; i++) {
if (!displays[i]->isDisplayLocked()) {
displays[i]->display(symbolId);
}
}
// Check if this symbol matches the current round target
bool allMatch = true;
for (int i = 0; i < 3; i++) {
if (displays[i]->getCurrentSymbol() != targetSequences[currentRound][i]) {
allMatch = false;
break;
}
}
// If all match, complete the round
if (allMatch) {
completeRound();
}
}
// Method to check for random wins
void checkForRandomWin() {
// Get the first display's symbol
int firstSymbol = displays[0]->getCurrentSymbol();
// Check if all displays show the same symbol
bool allSame = true;
for (int i = 1; i < 3; i++) {
if (displays[i]->getCurrentSymbol() != firstSymbol) {
allSame = false;
break;
}
}
// If all displays show the same symbol
if (allSame && firstSymbol >= 0) {
// Check if the matching symbols are the target sequence for current round
bool isTargetSequence = true;
for (int i = 0; i < 3; i++) {
if (displays[i]->getCurrentSymbol() != targetSequences[currentRound][i]) {
isTargetSequence = false;
break;
}
}
if (isTargetSequence) {
// Complete the current round
completeRound();
} else {
// Minor win - all symbols match but not the target sequence
Serial.println("Minor Win +£10");
moneyCount = moneyCount + 10;
Serial.print("£");
Serial.println(moneyCount);
}
}
}
// Method to handle completing a round
void completeRound() {
// Set displays to locked state so they keep showing the target sequence
for (int i = 0; i < 3; i++) {
displays[i]->forceLock();
}
// Award money
Serial.print("Round ");
Serial.print(currentRound + 1);
Serial.println(" Complete! +£20");
moneyCount = moneyCount + 20;
Serial.print("£");
Serial.println(moneyCount);
// Set round to complete and record time to auto-advance
roundComplete = true;
roundCompleteTime = millis();
// If this is the final round, add bonus
if (currentRound == 4) {
Serial.println("FINAL ROUND COMPLETE! Bonus +£100");
moneyCount = moneyCount + 100;
Serial.print("Final Balance: £");
Serial.println(moneyCount);
// Display completion message
Serial.println("Game will reset shortly");
} else {
// Display message about proceeding to next round
Serial.println("Proceeding to next round shortly");
}
}
void reset() {
for (int i = 0; i < 3; i++) {
displays[i]->reset();
displays[i]->setTargetSymbol(targetSequences[0][i]);
}
currentRound = 0;
roundComplete = false;
gameComplete = false;
moneyCount = 50;
// Show round message at the start
showRoundMessage();
Serial.print("Game Reset - Round 1 - Target: ");
Serial.println(getSymbolName(targetSequences[0][0]));
Serial.print("£");
Serial.println(moneyCount);
}
double getMoney() {
return moneyCount;
}
// Cleanuping function for memory management
~SlotMachine() {
delete cherrySymbol;
delete currencySymbol;
delete diamondSymbol;
delete barSymbol;
delete sevenSymbol;
for (int i = 0; i < 3; i++) {
delete displays[i];
}
}
};
// Main program
LiquidCrystal lcdOne(22, 23, 4, 5, 6, 7);
LiquidCrystal lcdTwo(24, 25, 10, 11, 12, 13);
LiquidCrystal lcdThree(14, 15, 16, 17, 18, 19);
const int buttonPin = 8;
SlotMachine* slotMachine;
void setup() {
Serial.begin(9600);
randomSeed(analogRead(A0));
lcdOne.begin(16, 2);
lcdTwo.begin(16, 2);
lcdThree.begin(16, 2);
slotMachine = new SlotMachine(buttonPin, &lcdOne, &lcdTwo, &lcdThree);
Serial.print("£");
Serial.println(slotMachine->getMoney());
// if (!slotMachine->isGameComplete()) {
// lcdOne.clear();
// lcdOne.print("hello");
// }
}
void loop() {
slotMachine->update();
}