|
1 | | -# Arduino LCD Mini-Games Console (Menu UI + Screensaver) |
| 1 | +# Arduino LCD Mini‑Games Console (Menu UI + Screensaver) — **V2** |
| 2 | +A collection of classic games and utilities for the Arduino Uno with a 16×2 LCD Keypad Shield. |
| 3 | +Navigate a menu to play games like Snake, Break the Bricks, Chrome Dino, Helicopter, and more — all on a simple LCD display! |
2 | 4 |
|
3 | | -A collection of classic games and utilities for the Arduino Uno with a 16x2 LCD Keypad Shield. |
4 | | -Navigate a menu to play games like Snake, Break the Bricks, Chrome Dino, Helicopter, and more—all on a simple LCD display! |
| 5 | + |
| 6 | +-brightgreen) |
| 7 | +-orange) |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## 📦 Build Footprint (V2) |
| 12 | + |
| 13 | +- **Flash (program storage):** **18,498 bytes (57%)** of 32,256 bytes |
| 14 | +- **SRAM (global variables):** **1,653 bytes (80%)** of 2,048 bytes → **395 bytes free** for locals/stack |
| 15 | + |
| 16 | +> **V1** previously consumed **~98%** of flash. V2 cuts that dramatically by de‑duplicating code, sharing a single `LiquidCrystal` + button reader, and embedding games under a unified UI. |
| 17 | +
|
| 18 | +*(Your numbers may vary slightly by IDE/toolchain version and enabled games.)* |
| 19 | + |
| 20 | +--- |
5 | 21 |
|
6 | 22 | ## 🧰 Hardware |
7 | 23 | - **Arduino Uno** (ATmega328P) |
8 | | -- **16×2 LCD Keypad Shield** (DFRobot-style, buttons via **A0** resistor ladder) |
9 | | - |
10 | | -## 🛠 Features |
| 24 | +- **16×2 LCD Keypad Shield** (DFRobot‑style, buttons via **A0** resistor ladder) |
11 | 25 |
|
12 | | -- **Menu UI**: Select games and utilities from a simple LCD menu ([UI/UI.ino](UI/UI.ino)) |
13 | | -- **Snake Game**: Classic snake with multiple levels ([snake_game/snake_game.ino](snake_game/snake_game.ino), [UI/snake_game.ino](UI/snake_game.ino)) |
14 | | -- **Break the Bricks**: Arkanoid-style brick breaker ([Break_the_Bricks/Break_the_Bricks.ino](Break_the_Bricks/Break_the_Bricks.ino), [UI/Break_the_Bricks.ino](UI/Break_the_Bricks.ino)) |
15 | | -- **Chrome Dino Game**: T-Rex runner clone ([Chrome_Dino/Chrome_Dino.ino](Chrome_Dino/Chrome_Dino.ino)), [UI/Chrome_Dino.ino](UI/Chrome_Dino.ino)) |
16 | | -- **Helicopter Game**: Dodge obstacles as a helicopter ([Helicopter_Game/Helicopter_Game.ino](Helicopter_Game/Helicopter_Game.ino), [UI/Helicopter_Game.ino](UI/Helicopter_Game.ino)) |
17 | | -- **Decision Compass**: Magic 8-ball style random answer generator ([Decision_Compass/Decision_Compass.ino](Decision_Compass/Decision_Compass.ino), [UI/Decision_Compass.ino](UI/Decision_Compass.ino)) |
18 | | -- **How Many Days Until**: Date calculator for days/months/years between two dates ([How_Many_Days_Until/How_Many_Days_Until.ino](How_Many_Days_Until/How_Many_Days_Until.ino), [UI/How_Many_Days_Until.ino](UI/How_Many_Days_Until.ino)) |
19 | | -- **Eye Animation**: Fun idle animation ([UI/EyeAnimation.ino](UI/EyeAnimation.ino)) |
| 26 | +## 🛠 Features (V2) |
| 27 | +- **Unified Menu UI** with clean app hand‑off (`runXYZ()` style) and **single** `LiquidCrystal`/button reader. |
| 28 | +- **Eye Animation screensaver** after **30 s** idle on the menu (any key returns). |
| 29 | +- **Namespaced buttons** to avoid macro clashes (`UI_BTN_*` in UI, `DINO_BTN_*` in Dino). |
| 30 | +- **Embed‑friendly games** (no duplicate `setup()/loop()`; use `extern LiquidCrystal lcd;` when embedded). |
20 | 31 |
|
21 | 32 | ## 🎮 Controls |
22 | 33 | LCD Keypad Shield buttons read through **A0**. The UI maps them to `UI_BTN_*` constants; games that need their own constants use a separate namespace (`DINO_BTN_*`). Typical actions: |
23 | 34 | - **UP/DOWN**: menu navigation |
24 | | -- **RIGHT/LEFT**: Game navigation |
| 35 | +- **RIGHT/LEFT**: game navigation (varies per game) |
25 | 36 | - **SELECT**: choose / start / restart |
26 | | -- **RST (RESET)**: commonly used as back/exit in some games or wrappers |
| 37 | +- **RESET (RST)**: resets the board (not used for in‑game back) |
27 | 38 |
|
28 | 39 | ## 🏗 Architecture |
29 | | -- **Single LCD instance**: `LiquidCrystal lcd(8,9,4,5,6,7)` lives in `UI.ino`. Games use `extern LiquidCrystal lcd;` when embedded. |
30 | | -- **Button reader**: one `read_LCD_buttons()` in `UI.ino`; games reuse via `extern` when embedded. |
31 | | -- **App runners**: each game exposes `void runXYZ();` which the UI calls (e.g., `runSnakeGame()`). |
32 | | -- **Screensaver**: `EyeAnimation` is called when `(millis() - lastActivityMs) >= 30000` while in `MENU` state. |
| 40 | +- **Single LCD instance**: `LiquidCrystal lcd(8,9,4,5,6,7)` lives in `UI/UI.ino`. Games use `extern LiquidCrystal lcd;` when embedded. |
| 41 | +- **Button reader**: one `read_LCD_buttons()` in `UI/UI.ino`; games reuse via `extern`. |
| 42 | +- **App runners**: each game exposes `void runXYZ();` (e.g., `runSnakeGame()`, `runHelicopter()`). |
| 43 | +- **Screensaver**: `EyeAnimation` auto‑runs when `(millis() - lastActivityMs) >= 30000` while in `MENU`. |
| 44 | +- **Dino embedding**: guarded by `#ifdef EMBED_DINO_IN_UI` → reuse UI LCD/buttons and rename entry points internally. |
33 | 45 |
|
34 | 46 | ## 🕹 Games & utilities |
35 | | -- **Chrome Dino**: two-cell T-Rex (CREA style), **cactus** (ground) + **bird** (top), **score-based tick speed**, fixed **Game Over** edge-case, HUD score. |
36 | | -- **Snake**: body stored as a **linked list**; food spawn, self-collision, incremental speed. |
37 | | -- **Break-the-Bricks**: paddle + bricks on 16×2; compact physics for character LCD. |
38 | | -- **Helicopter**: side-scroller with obstacle gaps. |
39 | | -- **Decision Compass**: pseudo-random choices (like a Magic-8). |
| 47 | +- **Chrome Dino**: two‑cell T‑Rex (CREA style), **cactus** (ground) + **bird** (top), **score‑based tick speed**, fixed **Game Over**, HUD score. |
| 48 | +- **Snake**: body stored as a **linked list**; food spawn, self‑collision, incremental speed. |
| 49 | +- **Break‑the‑Bricks**: paddle + bricks on 16×2; compact physics for character LCD. |
| 50 | +- **Helicopter**: side‑scroller with obstacle gaps. |
| 51 | +- **Decision Compass**: pseudo‑random answers (Magic‑8‑ball style). |
40 | 52 | - **How Many Days Until**: date/interval utility on the LCD. |
41 | 53 | - **Eye Animation**: used standalone and as the **idle screensaver**. |
42 | 54 |
|
|
66 | 78 | UI.ino |
67 | 79 | ``` |
68 | 80 |
|
| 81 | +## 🚀 Quick Start |
| 82 | +1. Open **`UI/UI.ino`** in Arduino IDE. |
| 83 | +2. Select **Board: Arduino Uno** and the correct **Port**. |
| 84 | +3. **Upload**. Use **UP/DOWN** to navigate, **SELECT** to launch a game. |
| 85 | +4. Idle on the menu for **30 s** to see the **Eye Animation** screensaver. |
| 86 | + |
| 87 | +## 🧪 Build Tips & Troubleshooting |
| 88 | +- **“Multiple libraries found for LiquidCrystal”**: Info message; the IDE picks one. Remove duplicates to silence. |
| 89 | +- **Macro clashes (`BTN_SELECT`)**: V2 uses **`UI_BTN_*`** in the UI and **`DINO_BTN_*`** in Dino to avoid conflicts. |
| 90 | +- **Duplicate `setup()/loop()`**: Only the UI should define them in menu builds. Standalone uploads should not include UI files. |
| 91 | +- **SRAM tight** (~80% used): keep locals small; prefer `static const`/`PROGMEM` for sprites; wrap strings with `F("...")` to move them to flash. |
| 92 | + |
| 93 | +## 🔁 What changed from V1 → V2 |
| 94 | +- De‑duplicated LCD/button code and removed placeholder stubs → **big flash reduction** (from **~98%** to **57%**). |
| 95 | +- Added **idle screensaver**, fixed **Game Over** edge‑case in Dino, and standardized input handling. |
| 96 | +- Made each game embed‑safe (no own `setup/loop` when running under the UI). |
| 97 | + |
69 | 98 | ## 🙌 Credits |
70 | | -- Chrome Dino sprite inspiration: **CREA ELECTRONICA** / **Max Imagination** (two-cell T-Rex look). |
71 | | -- Thanks to the Arduino community for the classic LCD Keypad Shield patterns and LiquidCrystal library examples. |
| 99 | +- Chrome Dino sprite inspiration: **CREA ELECTRONICA** / **Max Imagination** (two‑cell T‑Rex look). |
| 100 | +- Thanks to the Arduino community for the LCD Keypad Shield patterns and LiquidCrystal examples. |
72 | 101 |
|
73 | 102 | --- |
74 | 103 |
|
|
0 commit comments