Smarties Dispenser: ROS2 & Arduino
📌 Overview
The Controlled-Access Smarties Dispenser is an interactive IoT project that merges robotics, computer vision, and embedded systems. Built with a ROS2 stack and an Arduino core, the system challenges users through a multi-stage game flow—Smile Detection, Math Quiz, and a Blow Challenge—before rewarding them with candy.
- Role: Lead Developer (Systems Integration & Robotics)
- Technologies: ROS2 (Humble/Foxy), Arduino, Python, C++, OpenCV
- Key Hardware: Raspberry Pi (Camera), Arduino, Servo, IR Receiver, LCD, Blow Sensor
🏗️ System Architecture
The project is designed as a distributed system where high-level logic is handled by ROS2 nodes and low-level hardware interaction is managed by an Arduino bridge.
🧠 ROS2 Orchestration
face_smile_processor: Uses OpenCV Haar cascades to detect faces and smiles in real-time.game_master: A state machine node that manages the game flow and handles timing parameters (cooldowns, reward delays).math_quiz_node: Generates dynamic multiplication problems and validates user input from the IR remote.microcontroller_communicator: A serial bridge (/dev/ttyACM0) that translates ROS topics into Arduino-friendly serial commands.
📟 Arduino Peripheral Control
The Arduino acts as the “Hands and Senses” of the project:
- Sensors: Decodes IR remote signals and calibrates a blow sensor (A0) for the physical challenge.
- Feedback: Drives a 16x2 LCD for UI, an RGB LED for status, and a piezo buzzer for melodic feedback.
- Actuation: Controls a high-torque servo for the trapdoor mechanism.
🎮 The Game Flow
- Face/Smile Detection: The camera monitors the user. A smile triggers the start of the challenge.
- Math Quiz: An IR remote is used to answer a multiplication question displayed on the LCD. A 30s lockout is enforced on failure.
- Blow Challenge: The user must blow into the sensor to fill a “gauge” displayed on the LCD.
- Reward: Once validated, the trapdoor opens via servo, accompanied by a victory melody. A 30s cooldown prevents “candy spamming.”
📈 Technical Challenges & Solutions
-
Real-time Serial Communication: * Challenge: Ensuring low-latency communication between the ROS2 Python nodes and the C++ Arduino sketch.
-
Solution: Developed a custom command-string protocol (
SERVO_OPEN <ms>,MATH_Q a b) with robust error handling to prevent serial buffer overflows. -
Sensor Calibration:
-
Challenge: The blow sensor baseline fluctuated based on ambient conditions.
-
Solution: Implemented an auto-calibration routine at boot-up to map the delta between baseline and active input to a 0–100% scale.
🔗 Links & Resources
- Source Code: [View GitHub Repository]
- Documentation: [Full Hardware Wiring & Build Guide]
🚀 Developed by Evanescent.