/Arduino-Project

Arduino Icy Tower Motion Controller lets you play the classic Icy Tower game with motion controls! A wearable Arduino-based transmitter detects your head tilts and jumps, sending commands wirelessly to a receiver Arduino that emulates keyboard inputs for immersive retro gaming.

Primary LanguageC++

Arduino Icy Tower Motion Controller

A revolutionary way to play the nostalgic game Icy Tower using motion controls! This Arduino-based project creates an immersive gaming experience by detecting your head movements and translating them into game controls.

🎯 Project Overview

This project transforms the classic Icy Tower game into a motion-controlled experience using two Arduino units:

  • Transmitter Unit: A wearable device (designed as a hat) that monitors player movements
  • Receiver Unit: Connected to your computer to send keyboard commands to the game

The system detects head tilting (left/right movement) and jumping motions, wirelessly transmitting these actions to control the Icy Tower character.

🛠 Hardware Requirements

Transmitter Unit Components

  • Arduino Board (Arduino Uno, Nano, or compatible)
  • MMA8452Q Accelerometer - For motion detection
  • RF Transmitter Module (433MHz recommended)
  • Power Supply (Battery pack for portability)
  • Wires and Breadboard/PCB

Receiver Unit Components

  • Arduino Leonardo/Micro (required for HID keyboard functionality)
  • RF Receiver Module (433MHz, matching transmitter)
  • LEDs (3x) - Visual feedback for movements:
    • Left LED (Pin 7)
    • Right LED (Pin 5)
    • Jump LED (Pin 6)
  • Safety Button (Pin 12) - Enable/disable control
  • Wires and Breadboard/PCB

Additional Requirements

  • Computer running Icy Tower game
  • Hat or Head-mounted Setup for transmitter unit

📚 Software Requirements

Arduino Libraries

  1. VirtualWire Library - For RF communication

    Install via Arduino IDE Library Manager: Search "VirtualWire"
    
  2. SparkFun MMA8452Q Library - For accelerometer

    Install via Arduino IDE Library Manager: Search "SparkFun MMA8452Q"
    
  3. Wire Library - I2C communication (built-in)

  4. Keyboard Library - HID functionality (built-in with Leonardo/Micro)

Game Requirements

  • Icy Tower game installed on your computer
  • Game should be active and focused when using the controller

🔧 Installation & Setup

1. Hardware Assembly

Transmitter Unit Wiring:

MMA8452Q Accelerometer:
- VCC → Arduino 3.3V
- GND → Arduino GND  
- SDA → Arduino A4 (SDA)
- SCL → Arduino A5 (SCL)

RF Transmitter:
- VCC → Arduino 5V
- GND → Arduino GND
- DATA → Arduino Pin 12

Receiver Unit Wiring:

RF Receiver:
- VCC → Arduino 5V
- GND → Arduino GND
- DATA → Arduino Pin 11

LEDs:
- Left LED → Pin 7 (with 220Ω resistor)
- Right LED → Pin 5 (with 220Ω resistor)
- Jump LED → Pin 6 (with 220Ω resistor)

Safety Button:
- One terminal → Pin 12
- Other terminal → GND

2. Software Installation

  1. Download Arduino IDE (if not already installed)
  2. Install Required Libraries (see Software Requirements)
  3. Upload Code:
    • Upload Transmitter.ino to the transmitter Arduino
    • Upload Receiver.ino to the receiver Arduino (must be Leonardo/Micro)

3. Calibration

The motion detection thresholds are configurable in the transmitter code:

// In detectLeftOrRight() function
const double RightDetected = 0.3;   // Adjust for right tilt sensitivity
const double LeftDetected = -0.3;   // Adjust for left tilt sensitivity

// In detectJump() function  
const double JumpDetected = -0.2;   // Adjust for jump sensitivity

🎮 How to Use

Setup Process:

  1. Power on both units (transmitter and receiver)
  2. Connect receiver unit to your computer via USB
  3. Mount transmitter unit on your head/hat
  4. Launch Icy Tower on your computer
  5. Press and hold the safety button on receiver to enable controls

Playing:

  • Tilt your head LEFT → Character moves left
  • Tilt your head RIGHT → Character moves right
  • Jump/nod downward → Character jumps
  • LED indicators on receiver show active movements
  • Release safety button to disable controls

Safety Features:

  • Safety button must be held to activate controls (prevents accidental input)
  • Visual LED feedback confirms movement detection
  • Serial monitor output for debugging (115200 baud)

🔍 How It Works

Motion Detection Process:

  1. Accelerometer Reading: The MMA8452Q continuously measures acceleration in X, Y, and Z axes
  2. Movement Analysis:
    • Y-axis movement detects left/right head tilting
    • Z-axis movement detects jumping (downward acceleration)
  3. Threshold Comparison: Movements exceeding predefined thresholds trigger actions
  4. RF Transmission: Movement commands are sent wirelessly to receiver
  5. Keyboard Simulation: Receiver translates commands to keyboard inputs for the game

Communication Protocol:

The system uses a simple enum-based protocol:

enum MoveToSend{
    LEFT,           // Tilt left detected
    RIGHT,          // Tilt right detected  
    JUMP,           // Jump motion detected
    NOTHING_JUMP,   // Stop jumping
    NOTHING_SIDES,  // Stop left/right movement
    NOTHING         // No action
};

Code Structure:

Transmitter (Transmitter.ino):

  • Motion Detection: detectLeftOrRight() and detectJump() functions
  • RF Communication: sendData() function transmits movement data
  • Continuous Monitoring: Main loop processes accelerometer data

Receiver (Receiver.ino):

  • RF Reception: Receives movement commands via VirtualWire
  • Keyboard Control: Translates commands to arrow key presses
  • Visual Feedback: Controls LEDs based on active movements
  • Safety Control: Only processes commands when safety button is pressed

🔧 Troubleshooting

Common Issues:

No Response from Game:

  • Ensure receiver Arduino is Leonardo/Micro (required for HID)
  • Check that safety button is being held down
  • Verify game window is active and focused

Erratic Movement:

  • Adjust motion detection thresholds in code
  • Check accelerometer wiring and power supply
  • Ensure stable mounting of transmitter unit

RF Communication Problems:

  • Verify transmitter and receiver are on same frequency
  • Check antenna connections and range
  • Ensure both units are powered properly

LEDs Not Working:

  • Check LED polarity (long leg = positive)
  • Verify resistor values (220Ω recommended)
  • Test LED connections

Serial Debug Output:

Connect to the receiver's serial monitor (115200 baud) to see real-time movement detection:

LEFT
RIGHT  
JUMP
JUMP NOTHING
LEFT RIGHT NOTHING

🤝 Contributing

Contributions are welcome! Here are some ideas for improvements:

  • Enhanced motion detection algorithms
  • Wireless range improvements
  • Additional game compatibility
  • 3D printed enclosures
  • Battery optimization
  • Calibration interface

📝 License

This project is open source. Feel free to modify and distribute according to your needs.

🎊 Credits

Inspired by the classic Icy Tower game and the desire to create immersive motion-controlled gaming experiences.


Have fun playing Icy Tower like never before! 🎮✨