# polyed/micromouse architecture

> Architecture diagram of the GitHub repository polyed/micromouse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/polyed/micromouse
- Repository: https://github.com/polyed/micromouse

## Overview

##### Main Components

a. Hardware Components:
- Arduino Uno Rev3 (Main Controller)
- Sensors:
- ADXL335 (Accelerometer/Gyroscope)
- HMC5883 (Magnetometer)
- VL53L0X (Time of Flight Sensor)
- Motors and Encoders (12cpr)
- PCB Design (from Eagle Files)

b. Software Components:
- Maze Solving Algorithms
- Flood Fill Implementation
- Multiple Versions (C and Python implementations)
- Sensor Integration
- Motor Control
- Data Plotting/Visualization

**[Hardware Layer]**
- ↕
**[Control Layer]**
- ↕
**[Algorithm Layer]**

##### Specific Elements

a. Hardware Layer:
- Sensors with I2C bus indication
- Motor controllers and encoders
- PCB integration points

b. Control Layer:
- Sensor data processing modules
- Motor control interface
- I2C communication handlers
- Data plotting/visualization components

c. Algorithm Layer:
- Flood fill algorithm implementation
- Maze mapping system
- Navigation logic
- Path optimization

##### Important Relationships to Highlight

- I2C Communication paths between sensors and Arduino
- Data flow from sensors to algorithm layer
- Control signals from algorithm to motors
- Debug/visualization data flow to plotting system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Hardware
        Arduino["Arduino Uno Rev3"]
        Sensors["Sensor Hub"]
        Motors["Motors & Encoders"]
        PCB["PCB Design"]
        
        Sensors --> |I2C| Arduino
        Motors --> |Digital IO| Arduino
        PCB --> |Integration| Arduino
        
        subgraph Sensors
            ADXL["ADXL335<br/>Accel/Gyro"]
            HMC["HMC5883<br/>Magnetometer"]
            TOF["VL53L0X<br/>Time of Flight"]
        end
    end
    
    subgraph Control
        SensorInt["Sensor Integration"]
        MotorCtrl["Motor Control"]
        I2CComm["I2C Communication"]
        DataVis["Data Visualization"]
        
        Arduino --> SensorInt
        Arduino --> MotorCtrl
        I2CComm --> SensorInt
        SensorInt --> DataVis
    end
    
    subgraph Algorithm
        FloodFill["Flood Fill Algorithm"]
        MazeMap["Maze Mapping"]
        NavLogic["Navigation Logic"]
        
        subgraph Implementations
            CImpl["C Implementation"]
            PyImpl["Python Implementation"]
        end
        
        FloodFill --> MazeMap
        MazeMap --> NavLogic
        NavLogic --> MotorCtrl
    end
    
    %% Click events for component mapping
    click Arduino "https://github.com/PolyEd/MicroMouse/tree/main/Arduino Uno Rev3"
    click ADXL "https://github.com/PolyEd/MicroMouse/tree/main/ADXL335 Gyro+Accel"
    click HMC "https://github.com/PolyEd/MicroMouse/tree/main/HMC5883 Magnetometer"
    click TOF "https://github.com/PolyEd/MicroMouse/tree/main/VL53L0X"
    click PCB "https://github.com/PolyEd/MicroMouse/tree/main/Eagle Files/Micromouse Eagle Project"
    click Motors "https://github.com/PolyEd/MicroMouse/blob/main/Datasheets/12cpr encoder spec sheet.pdf"
    click FloodFill "https://github.com/PolyEd/MicroMouse/blob/main/real micromouse/floodFillInC/maze.c"
    click SensorInt "https://github.com/PolyEd/MicroMouse/tree/main/micro_suite"
    click MotorCtrl "https://github.com/PolyEd/MicroMouse/blob/main/micro_suite/motor_go/motor_go.ino"
    click DataVis "https://github.com/PolyEd/MicroMouse/blob/main/ADXL335 Gyro+Accel/ADXL335_plotter/ADXL335_plotter.ino"
    click I2CComm "https://github.com/PolyEd/MicroMouse/blob/main/I2C-README.md"
    click CImpl "https://github.com/PolyEd/MicroMouse/blob/main/old micromouse/ethan/maze.c"
    click PyImpl "https://github.com/PolyEd/MicroMouse/blob/main/real micromouse/v1 software/main.py"
    
    %% Styling
    classDef hardware fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef control fill:#b3ffb3,stroke:#333,stroke-width:2px
    classDef algorithm fill:#ffffb3,stroke:#333,stroke-width:2px
    classDef communication fill:#ffb3b3,stroke:#333,stroke-width:2px
    
    class Arduino,Sensors,Motors,PCB,ADXL,HMC,TOF hardware
    class SensorInt,MotorCtrl,DataVis control
    class FloodFill,MazeMap,NavLogic,CImpl,PyImpl algorithm
    class I2CComm communication
```
