Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:abirlica:mariapana [2025/05/16 21:27]
maria.pana [Schematic]
pm:prj2025:abirlica:mariapana [2025/05/28 22:18] (current)
maria.pana [Bill of Materials]
Line 1: Line 1:
 +{{:​pm:​prj2025:​abirlica:​logo_ffgp.png?​100 |}}
 ====== Five Finger Game Punch ====== ====== Five Finger Game Punch ======
  
Line 25: Line 26:
 In addition, a button is placed near the thumb, allowing it to be easily pressed like a trigger (similar to a detonator). This button is mapped to an action key, such as left-click or attack, enabling interaction with the game environment (e.g., breaking blocks, hitting mobs). In addition, a button is placed near the thumb, allowing it to be easily pressed like a trigger (similar to a detonator). This button is mapped to an action key, such as left-click or attack, enabling interaction with the game environment (e.g., breaking blocks, hitting mobs).
  
-{{ :​pm:​prj2025:​abirlica:​schema_bloc_ffgp.png?600 |}}+{{ :​pm:​prj2025:​abirlica:​proiectpmffgp.jpg?600 |}}
  
 The MPU6050 communicates with the Arduino Uno via the I2C protocol. The Arduino processes the data and transmits it via UART to an HC05 Bluetooth module. On the PC side, a program receives the Bluetooth data and emulates keyboard input, making the glove behave like a motion-enabled controller. The MPU6050 communicates with the Arduino Uno via the I2C protocol. The Arduino processes the data and transmits it via UART to an HC05 Bluetooth module. On the PC side, a program receives the Bluetooth data and emulates keyboard input, making the glove behave like a motion-enabled controller.
Line 36: Line 37:
  
 ^ Component ​     ^ Description ​    ^ Link          ^ ^ Component ​     ^ Description ​    ^ Link          ^
-| Arduino Uno    | Microcontroller | [[https://www.digikey.ro/en/products/detail/​arduino/​A000066/​2784006|Link]] ​      |+| Arduino Uno    | Microcontroller | [[https://ww1.microchip.com/​downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf ​| Link]] ​      |
 | MPU6050 ​   | Accelerometer & Gyroscope Sensor ​   | [[https://​cdn.sparkfun.com/​datasheets/​Components/​General%20IC/​PS-MPU-6000A.pdf |Link]] ​      | | MPU6050 ​   | Accelerometer & Gyroscope Sensor ​   | [[https://​cdn.sparkfun.com/​datasheets/​Components/​General%20IC/​PS-MPU-6000A.pdf |Link]] ​      |
 | HC05    | Bluetooth Module ​   | [[https://​components101.com/​sites/​default/​files/​component_datasheet/​HC-05%20Datasheet.pdf |Link]] ​      | | HC05    | Bluetooth Module ​   | [[https://​components101.com/​sites/​default/​files/​component_datasheet/​HC-05%20Datasheet.pdf |Link]] ​      |
-1571563-8 ​   | Button ​   | [[https://ro.mouser.com/datasheet/2/418/7/ENG_CD_2_1437565_7_V-2027941.pdf |Link]] ​      |+3433    ​| ​Arcade ​Button ​   | [[https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/​39/​3433_Web.pdf |Link]] ​      |
 | 9V Battery ​   | Power Supply ​   | [[https://​www.dedeman.ro/​ro/​baterie-varta-longlife-power-6lr61/​-6lp3146-9v-alcalina-1-buc/​p/​1005948?​srsltid=AfmBOor-XSLL2JOhBWzI5F-8HP-SR9m6TvWrXkO_EpkHgMgf4OyaEI3SIYA&​gQT=1 |Link]] ​      | | 9V Battery ​   | Power Supply ​   | [[https://​www.dedeman.ro/​ro/​baterie-varta-longlife-power-6lr61/​-6lp3146-9v-alcalina-1-buc/​p/​1005948?​srsltid=AfmBOor-XSLL2JOhBWzI5F-8HP-SR9m6TvWrXkO_EpkHgMgf4OyaEI3SIYA&​gQT=1 |Link]] ​      |
  
 ==== Schematic ==== ==== Schematic ====
  
-{{ :​pm:​prj2025:​abirlica:​screenshot_2025-05-05_212714.png?500 |}}+{{ :​pm:​prj2025:​abirlica:​sch_el_ffgp.png?500 |}}
 ===== Software Design ===== ===== Software Design =====
  
Line 56: Line 57:
 </​note>​ </​note>​
  
-===== Rezultate Obţinute =====+==== Used Pins ====
  
-<note tip> +The MPU6050 gyroscope and accelerometer module is interfaced using the Arduino Uno’s I2C communication protocol. Specifically,​ pins A4 and A5 are used, where A4 (PC4) serves as the SDA (data line) and A5 (PC5) serves as the SCL (clock line). These pins are chosen because the ATmega328P microcontroller provides dedicated hardware support for I2C on these lines. The MPU6050 is powered via the 3.3V line and protected by a voltage divider.
-Care au fost rezultatele obţinute în urma realizării proiectului vostru. +
-</​note>​+
  
-===== Concluzii =====+For user interaction,​ an Arcade Button (3343) is connected with a combined LED and data line setup. The button'​s input is read on digital pin D8 (PB0), while the LED is powered from the 5V supply and grounded through GND. Pin D8 is strategically selected to avoid conflicts with critical communication pins - such as A4/A5 used for I2C, D0/D1 used for UART, and D10–D13 reserved for SPI - leaving these interfaces free for future expansion. Furthermore,​ D8 is compatible with Timer2-based interrupts, which are utilized for polling the button at 2kHz (every 0.5 milliseconds).
  
-===== Download =====+The HC05 Bluetooth module is interfaced via the Arduino’s hardware UART on pins D0 and D1. Specifically,​ the HC05’s RX pin is connected to Arduino TX (D1/PD1), and its TX pin to Arduino RX (D0/PD0). These are the default UART pins on the ATmega328P, providing direct access to the USART0 peripheral. The HC05 is powered via the 5V line and protected by a voltage divider.
  
-<note warning>​ +===== Software Design =====
-O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului:​ surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-).+
  
-Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:​pm:​prj20??:​c?​** sau **:​pm:​prj20??:​c?:​nume_student** (dacă este cazul). **Exemplu:​** Dumitru Alin331CC -> **:​pm:​prj2009:​cc:​dumitru_alin**. +Although I initially started developing the code in Arduino IDE and used its provided libraries, once I got the project working I replaced the library code with my own implementationstargeting my use case and applying the knowledge gained during the laboratories.
-</​note>​+
  
-===== Jurnal =====+At its core, the software is composed of two parts: the C code for the Arduino and the Python code for the PC.
  
-<note tip> +{{ :​pm:​prj2025:​abirlica:​ffgp_sw_diagram.png?600 |}}
-Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. +
-</​note>​+
  
-===== Bibliografie/​Resurse =====+==== Arduino Side ====
  
-<​note>​ +=== 1Initialization ===
-Listă cu documente, datasheet-uri,​ resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. +
-</​note>​+
  
-<​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​+Upon powering on, the Arduino initializes its hardware components with low-level control:
  
 +  * **I2C Interface**
 +    * Configured using //direct register manipulation//​ instead of the standard ''​Wire''​ library.
 +    * Sends initialization commands to the **MPU6050** sensor to wake it from sleep and enable accelerometer and gyroscope output.
 +
 +  * **Bluetooth Communication (UART)**
 +    * Implemented using //​bit-banged UART// on digital I/O pins.
 +    * Baud rate is controlled precisely using **timers** for accurate bit timing.
 +    * Originally used ''​SoftwareSerial'',​ but replaced due to interrupt conflicts.
 +
 +=== 2. Main Loop ===
 +
 +The main loop handles continuous data processing and user input detection:
 +
 +  * **Sensor Data Handling**
 +    * Reads accelerometer values from the **MPU6050** over I2C.
 +    * Processes raw X and Y axis data.
 +    * Converts values into roll and pitch.
 +
 +  * **Command Generation**
 +    * Based on tilt direction, determines movement commands:
 +      * ''​W''​ = Forward
 +      * ''​A''​ = Left
 +      * ''​S''​ = Backward
 +      * ''​D''​ = Right
 +    * Ensures **mutually exclusive** movement — only one direction is sent at a time.
 +
 +=== 3. Button Handling ===
 +
 +  * **Button Input**
 +    * Connected to a digital pin with **interrupt-driven debounce** logic.
 +    * **Timer2** used to trigger debounce checks every 1 ms.
 +    * Differentiates between:
 +      * **Short press** = Left-click
 +      * **Long press** = Interpreted as multiple short presses
 +
 +  * **Timer2 Justification**
 +    * Initially used ''​SoftwareSerial'',​ which **disables all interrupts** during communication.
 +    * Timer2 was adopted as a workaround and retained even after switching away from ''​SoftwareSerial''​.
 +
 +=== 4. Heartbeat Mechanism ===
 +
 +  * Sends a **heartbeat signal** (''​H''​) every 2 seconds.
 +  * Ensures the PC side knows the Arduino is still connected and responsive.
 +
 +==== PC Side (Python Script) ====
 +
 +=== 1. Serial Communication ===
 +
 +  * Opens a **serial connection** to the Bluetooth module (recognized as a virtual COM port).
 +  * Continuously **listens** for incoming characters from the Arduino.
 +
 +=== 2. Command Handling ===
 +
 +  * **Movement Characters** (''​W'',​ ''​A'',​ ''​S'',​ ''​D''​):​
 +    * Uses the ''​pynput''​ library to simulate key presses.
 +    * Smoothly switches between keys — previous key is released before a new one is pressed.
 +
 +  * **Mouse Click (''​B''​)**
 +    * Triggers a quick **left-click** event.
 +
 +  * **Heartbeat (''​H''​)**
 +    * Acknowledged by the script to confirm that communication is active.
 +
 +=== 3. Performance Considerations ===
 +
 +  * **Non-blocking architecture**
 +  * Python script runs a continuous loop with **event logging** for debugging and monitoring.
 +
 +
 +===== Conclusions & Demo =====
 +
 +Now that the glove itself is also done, the "final product"​ is ready to go. The project works as intended i.e. both movement and interaction are controlled accordingly by the glove. To get a glimpse of how using it looks like, check out this demo:
 +
 +<​html>​ <iframe width="​560"​ height="​315"​ src="​https://​www.youtube.com/​embed/​N01kTD3kd4o?​si=A8gSA9WULjpobjY_"​ title="​YouTube video player"​ frameborder="​0"​ allow="​accelerometer;​ autoplay; clipboard-write;​ encrypted-media;​ gyroscope; picture-in-picture;​ web-share"​ referrerpolicy="​strict-origin-when-cross-origin"​ allowfullscreen></​iframe>​ </​html>​
 +
 +[[https://​www.youtube.com/​watch?​v=N01kTD3kd4o | Click here for demo video]]
 +
 +{{:​pm:​prj2025:​abirlica:​ffgp_4.jpeg?​150 |}}
 +
 +{{:​pm:​prj2025:​abirlica:​ffgp_2.jpeg?​150 |}}
 +
 +{{:​pm:​prj2025:​abirlica:​ffgp_1.jpeg?​150 |}}
 +
 +{{:​pm:​prj2025:​abirlica:​ffgp_3.jpeg?​150 |}}
 +
 +===== Downloads =====
 +
 +{{:​pm:​prj2025:​abirlica:​five_finger_game_punch_downloads.zip|}}
 +
 +===== Bibliography =====
 +
 +Hardware Resources:
 +
 +  * [[https://​ww1.microchip.com/​downloads/​en/​DeviceDoc/​Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf | ATmega328P Datasheet]]
 +  * [[https://​cdn.sparkfun.com/​datasheets/​Components/​General%20IC/​PS-MPU-6000A.pdf | MPU6050 Datasheet]]
 +  * [[https://​components101.com/​sites/​default/​files/​component_datasheet/​HC-05%20Datasheet.pdf | HC05 Datasheet]]
 +
 +Software Resources:
 +  * [[https://​pypi.org/​project/​pynput/​ | Pynput]]
 +  * [[https://​pypi.org/​project/​pyserial/​ | Pyserial]]
 +  * [[https://​www.youtube.com/​watch?​v=7VW_XVbtu9k&​t=389s | Computing angles for MPU6050]]
 +
 +Miscellaneous resources (mainly for working out issues):
 +  * [[https://​www.youtube.com/​watch?​v=GlkFYAMBhoU | Wiring Arcade Buttons]]
 +  * [[https://​www.instructables.com/​Plug-and-Play-Arcade-Buttons/​ | Realising the only available solution to use the arcade button was to solder jumper wires to the button pins]]
 +  * [[https://​arduino.stackexchange.com/​questions/​68783/​cant-power-up-arduino-from-dc-jack | A helpful resource in trying to find out why the 9V battery wasn't powering the board (Hint: your board works fine, try a fresh battery)]]
 +
 +<​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​
pm/prj2025/abirlica/mariapana.1747420078.txt.gz · Last modified: 2025/05/16 21:27 by maria.pana
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