How enricoferraiolo/tetris_arduino works
Project type and purpose
• This is an embedded‐firmware project for an Arduino UNO implementing a Tetris game.
• It uses multiple hardware peripherals (IR remote, IR receiver, LCD, rotary encoder, MAX7219 LED matrix) and can run on real hardware or in the Wokwi simulator via PlatformIO.
File structure
• Top level:
• platformio.ini – build/deployment config for Arduino UNO.
• src/main.cpp – core application.
• lib/ir_utils – IR code utilities library.
• – any additional headers (currently only a README).
• Altro – example sketches (IR, MAX7219) kept for reference.
• test – placeholder for future unit tests.
• Patterns: single‐target firmware, one main binary, one custom library, simulation assets.
README for additional insights
• Hardware pin mappings for each peripheral.
• Production vs. simulation mode in main.cpp.
• Required Arduino libraries: IRremote, LiquidCrystal, LedControl.
• Wokwi usage: build via PlatformIO, then run simulator.
a. Main components
• Arduino UNO (central controller)
• IR Receiver Module
• IR Remote (external input)
• Rotary Encoder Module
• 16×2 LCD Display
• 8×8 LED Matrix (MAX7219)
b. Relationships & interactions
• IR Remote → IR Receiver → IR utilities → main logic
• Rotary Encoder → digital pins → main logic
• main logic → LiquidCrystal library → LCD
• main logic → LedControl library → MAX7219 LED matrix
• main logic state machine (game logic) mediates all I/O and updates displays
• PlatformIO → compiles code → .pio/build/uno/firmware.hex → Wokwi / real board
c. Architectural patterns & design principles
• Single‐process event loop: read inputs, update game state, write outputs each iteration
• Separation of concerns: hardware‐specific utils in lib/ir_utils, display drivers via Arduino libraries, game logic in main.cpp
• Configuration toggles (PRODUCTION flag) to switch between hardware and simulator IR codes
d. Key technologies/frameworks
• Arduino core for UNO
• PlatformIO for build management
• Wokwi for simulation
• IRremote, LiquidCrystal, LedControl libraries
• C++ code organized into src/ and lib/