This is an old revision of the document!


Smart Puzzle Game

Introduction

The purpose of this project is to build an interactive puzzle box based on the ATmega328P Xplained Mini microcontroller. When the user presses the start button, the box opens using a servo motor and starts a timed puzzle challenge. The system displays the current level and the remaining time on an LCD, and it uses LEDs and a buzzer to signal success or failure.

The main idea behind the project is to combine a simple game-like experience with embedded control, timing, sound feedback, and multiple difficulty levels. The project started from the idea of a simple access system, but it later evolved into a puzzle-based interactive system, which is more interesting from both the hardware and software point of view.

We chose this idea because it is interactive, easy to demonstrate, and allows us to combine several topics studied during the laboratory sessions, especially interrupts, timers/PWM, and UART for debugging. We think the project is useful for us because it gives us practical experience with both hardware and software integration.

General Description

The project is built around the ATmega328P Xplained Mini, which controls all the hardware components. The system has the following main modules:

  • Main control unit – the ATmega328P Xplained Mini microcontroller coordinates the entire system.
  • Input module – one button starts the game, one button confirms the end of the round, and one reset/next button can be used to restart or move to the next level.
  • Display module – a 16×2 LCD shows the current level, remaining time, and result messages.
  • Actuation module – a servo motor opens the box when the game starts.
  • Feedback module – LEDs and a buzzer indicate game status, success, timeout, or errors.
  • Game logic module – software manages the countdown, level difficulty, state transitions, and result validation.

A simple logical flow of the system is the following:

  • the system waits in an idle state
  • the user presses the Start button
  • the servo opens the box
  • the LCD shows the current level and the countdown timer
  • the user completes the challenge
  • the user presses the Finish button
  • if the challenge is completed before timeout, the system shows success and moves to the next level
  • if the timer reaches zero first, the system signals failure

The project can be described using the following software states:

  • Idle
  • Opening Box
  • Game Running
  • Success
  • Fail / Timeout
  • Next Level / Reset

Block Diagram

The following block diagram presents the main hardware modules of the system and the way they interact. The ATmega328P Xplained Mini is the central control unit. It receives input from the buttons, controls the LCD, drives the servo motor, activates the buzzer and LEDs, and can optionally communicate with a PC through UART for debugging.

Untitled Diagram.drawio.html

Hardware Design

Components list

  • 1 x ATmega328P Xplained Mini microcontroller
  • 1 x USBasp programmer
  • 1 x 16 MHz crystal
  • 2 x 22 pF ceramic capacitors
  • 2-3 x 100 nF capacitors
  • 1 x 10 uF electrolytic capacitor
  • 1 x 100 uF electrolytic capacitor
  • 1 x 10 kOhm resistor
  • 2 x 220 Ohm resistors
  • 1 x reset button
  • 2-3 x push buttons for game control
  • 1 x 16×2 LCD, 5V
  • 1 x SG90 micro servo motor
  • 1 x active 5V buzzer
  • 1 x green LED
  • 1 x red LED
  • 1 x breadboard
  • jumper wires
  • 1 x box used as the main game enclosure

Hardware description

The ATmega328P Xplained Mini is the main controller and will be placed on a breadboard together with the supporting passive components. A 16 MHz crystal and two 22 pF capacitors will be used for stable clock generation. The reset pin will use a push button and a 10 kOhm pull-up resistor.

The LCD will display the current level, the timer, and game messages such as:

  • “Press Start”
  • “Level 1”
  • “Time left: 45 s”
  • “Success”
  • “Time over”

The servo motor will be used to physically open the box. Because the servo may create small voltage fluctuations, a larger capacitor (100 uF) will be placed on the power rail for stabilization.

The buzzer will provide sound notifications:

  • game start
  • warning near timeout
  • success
  • failure

The LEDs will provide simple visual feedback:

  • green LED = success
  • red LED = failure or timeout

The buttons will be used as follows:

  • Start button – starts the round and opens the box
  • Finish button – confirms the end of the round
  • Reset / Next button – moves to the next level or restarts the game

Covered laboratory topics

The project is designed to cover at least three laboratory topics from the course, not counting Lab 0.

  • Lab 1 – UART
    • sending debug messages to a PC terminal
    • printing the current state of the system
    • displaying information such as level, remaining time, success, or failure
  • Lab 2 – Interrupts
    • handling button events
    • reacting to time-based events more efficiently
    • improving responsiveness of the game logic
  • Lab 3 – Timers / PWM
    • implementing the countdown timer
    • generating the PWM signal for servo control
    • controlling timing for buzzer and visual feedback

Optionally, the project may also include:

  • Lab 6 – I2C
    • if an I2C LCD adapter is used, the display can be controlled through the I2C interface

Although GPIO is naturally used in the project for buttons, LEDs, and basic control signals, the core requirement of covering at least three laboratories is satisfied through UART, Interrupts, and Timers/PWM.

Software Design

Conclusions

Jurnal

pm/prj2026/jan.vaduva/33160.1778355159.txt.gz · Last modified: 2026/05/09 22:32 by tudor_mihai.petcu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0