# byt-ctrl/arduino-led-gesture architecture

> Architecture diagram of the GitHub repository byt-ctrl/arduino-led-gesture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/byt-ctrl/arduino-led-gesture
- Repository: https://github.com/byt-ctrl/arduino-led-gesture

## Overview

##### Main Components
a. Hardware
- Webcam (video input)
- Host Computer (runs Python code)
- Arduino Uno (runs StandardFirmata firmware)
- LED Array (5 LEDs + resistors + jumper wires)
b. Software
- Python Application
- VideoCapture Module (OpenCV)
- Hand-Tracking Module (MediaPipe)
- Gesture Logic (finger counting → mapping to LED count)
- Arduino Interface (PyFirmata serial communication)
- Arduino Firmware
- StandardFirmata (handles incoming commands, toggles pins)

##### Interactions and Data Flows
1) Webcam → VideoCapture (raw frames)
2) VideoCapture → Hand-Tracking (detect landmarks)
3) Hand-Tracking → Gesture Logic (compute N fingers held up)
4) Gesture Logic → Arduino Interface (send “set digital pin 1..N HIGH”)
5) Arduino Interface → Serial over USB → Arduino Uno Firmware
6) Arduino Firmware → Digital I/O pins → LED hardware

##### Architectural Patterns
- Real-time processing loop in Python: capture → process → actuate.
- Separation of concerns: Vision (OpenCV + MediaPipe) vs. Control (PyFirmata).
- External firmware (Firmata) as a thin hardware abstraction layer.

##### Technologies and Frameworks
- OpenCV (cv2) for frame grabbing
- MediaPipe for hand-landmark detection
- PyFirmata for serial messaging to Arduino
- StandardFirmata on the Arduino side
- Python 3.7–3.10

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Software Zone"
        VC["VideoCapture<br/>(OpenCV)"]:::software
        HT["Hand-Tracking<br/>(MediaPipe)"]:::software
        GL["Gesture Logic<br/>(finger count)"]:::software
        AI["Arduino Interface<br/>(PyFirmata)"]:::software
    end

    subgraph "Hardware Zone"
        WC["Webcam"]:::hardware
        USB["USB Port<br/>(PyFirmata)"]:::hardware
        UNO["Arduino Uno"]:::hardware
        SF["StandardFirmata"]:::hardware
        LED["LED Circuit<br/>(5 LEDs)"]:::hardware
    end

    subgraph "Documentation"
        RD["README.md"]:::external
        LIC["LICENSE"]:::external
    end

    WC -->|"1: frames"| VC
    VC -->|"2: landmarks"| HT
    HT -->|"3: finger count"| GL
    GL -->|"4: set pins"| AI
    AI -->|"5: USB / PyFirmata"| USB
    USB -->|"serial"| UNO
    UNO -->|"digital I/O"| LED
    LED -.->|"real-time loop"| VC

    click VC "https://github.com/byt-ctrl/arduino-led-gesture/blob/main/main-python-file.py"
    click HT "https://github.com/byt-ctrl/arduino-led-gesture/blob/main/main-python-file.py"
    click GL "https://github.com/byt-ctrl/arduino-led-gesture/blob/main/controller.py"
    click AI "https://github.com/byt-ctrl/arduino-led-gesture/blob/main/controller.py"
    click SF "https://github.com/byt-ctrl/arduino-led-gesture/tree/main/public-standard-pyFirmata/"
    click RD "https://github.com/byt-ctrl/arduino-led-gesture/blob/main/README.md"
    click LIC "https://github.com/byt-ctrl/arduino-led-gesture/tree/main/LICENSE"

    classDef software fill:#E0F7FA,stroke:#333,stroke-width:1px
    classDef hardware fill:#E8F5E9,stroke:#333,stroke-width:1px
    classDef external fill:#FFF3E0,stroke:#333,stroke-width:1px
```
