# faroub/tahakomavrlib architecture

> Architecture diagram of the GitHub repository faroub/tahakomavrlib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/faroub/tahakomavrlib
- Repository: https://github.com/faroub/tahakomavrlib

## Overview

TahakomAVRLib is a C++ hardware-abstraction library for Atmel AVR microcontrollers, with example applications demonstrating how a program turns inputs into hardware behavior or communication. The graph shows the four documented examples and the library’s component, MCU-peripheral, and low-level I/O layers. App-to-library links and internal links are based on README statements or the SOURCE INDEX reference lists; unsampled peripheral implementations are included as capabilities, without inferred call chains.

Main entry points: [`lib/io/Pin.cpp`](https://github.com/faroub/tahakomavrlib/blob/master/lib/io/Pin.cpp) (GPIO pins), [`applications/LightMeter/main.cpp`](https://github.com/faroub/tahakomavrlib/blob/master/applications/LightMeter/main.cpp) (Light meter), [`applications/MusicBox/main.cpp`](https://github.com/faroub/tahakomavrlib/blob/master/applications/MusicBox/main.cpp) (Music box), [`applications/Organ/main.cpp`](https://github.com/faroub/tahakomavrlib/blob/master/applications/Organ/main.cpp) (Square-wave organ)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_examples["Example applications"]
  node_blink["LED blink<br/>[main.cpp]"]
  node_lightmeter["Light meter<br/>[main.cpp]"]
  node_musicbox["Music box<br/>[main.cpp]"]
  node_organ["Square-wave organ<br/>[main.cpp]"]
end

subgraph group_components["External components"]
  node_led["LED control<br/>[Led.cpp]"]
  node_button["Push button<br/>[PushButton.cpp]"]
  node_buzzer["Buzzer<br/>[Buzzer.cpp]"]
  node_ldr["Light sensor<br/>[LDR.cpp]"]
  node_servo["Servo motor<br/>[ServoMotor.cpp]"]
  node_dc_motor["DC motor<br/>[DCMotor.cpp]"]
  node_stepper["Stepper motor<br/>[StepperMotor.cpp]"]
  node_lcd["LCD<br/>[LCD.cpp]"]
end

subgraph group_core["MCU peripherals"]
  node_mcu["MCU control<br/>[MCU.cpp]"]
  node_adc["ADC<br/>[ADC.cpp]"]
  node_interrupts["External interrupts"]
  node_timer["Timer interface<br/>[TimerCounter.h]"]
  node_timer0["Timer counter 0<br/>[TimerCounter0.cpp]"]
  node_timer1["Timer counter 1<br/>[TimerCounter1.cpp]"]
  node_timer2["Timer counter 2<br/>[TimerCounter2.cpp]"]
  node_watchdog["Watchdog timer<br/>[WatchdogTimer.cpp]"]
  node_comparator["Analog comparator<br/>[AnalogComparator.h]"]
end

subgraph group_io["I/O and support"]
  node_pin["GPIO pins<br/>[Pin.cpp]"]
  node_usart["USART0<br/>[USART0.cpp]"]
  node_spi["SPI<br/>[SPI.cpp]"]
  node_chip_config["ATmega328P definitions<br/>[ha_m328p.h]"]
  node_base["AVR base support<br/>[ha_base.h]"]
  node_pitch_data["Buzzer pitch tables"]
  node_utils["MCU utilities<br/>[utils_m328p.cpp]"]
end

node_developer(("Programmer"))
node_avr(("AVR microcontroller"))

node_developer -->|"runs example"| node_blink
node_developer -->|"runs example"| node_lightmeter
node_developer -->|"runs example"| node_musicbox
node_developer -->|"runs example"| node_organ
node_blink -->|"controls LED"| node_led
node_lightmeter -->|"controls LED"| node_led
node_lightmeter -->|"reads light"| node_ldr
node_lightmeter -->|"samples input"| node_adc
node_musicbox -->|"plays tones"| node_buzzer
node_musicbox -->|"reads presses"| node_button
node_musicbox -->|"uses pitches"| node_pitch_data
node_organ -->|"plays tones"| node_buzzer
node_organ -->|"uses serial"| node_usart
node_organ -->|"uses pitches"| node_pitch_data
node_led -->|"uses pin"| node_pin
node_button -->|"uses pin"| node_pin
node_buzzer -->|"uses pin"| node_pin
node_buzzer -->|"configures timer"| node_timer
node_ldr -->|"uses pin"| node_pin
node_ldr -->|"uses converter"| node_adc
node_servo -->|"uses pin"| node_pin
node_servo -->|"configures timer"| node_timer1
node_dc_motor -->|"uses pin"| node_pin
node_dc_motor -->|"uses timer"| node_timer0
node_stepper -->|"uses pin"| node_pin
node_timer0 -->|"implements interface"| node_timer
node_timer1 -->|"implements interface"| node_timer
node_timer2 -->|"implements interface"| node_timer
node_adc -->|"uses pin"| node_pin
node_interrupts -->|"references input"| node_button
node_interrupts -->|"references output"| node_led
node_spi -->|"uses pin"| node_pin
node_mcu -.->|"controls hardware"| node_avr
node_pin -.->|"accesses registers"| node_avr
node_usart -.->|"uses peripheral"| node_avr
node_spi -.->|"uses peripheral"| node_avr
node_base -->|"includes definitions"| node_chip_config
node_base -->|"includes utilities"| node_utils

click node_blink "https://github.com/faroub/tahakomavrlib/blob/master/applications/BlinkLed/main.cpp"
click node_lightmeter "https://github.com/faroub/tahakomavrlib/blob/master/applications/LightMeter/main.cpp"
click node_musicbox "https://github.com/faroub/tahakomavrlib/blob/master/applications/MusicBox/main.cpp"
click node_organ "https://github.com/faroub/tahakomavrlib/blob/master/applications/Organ/main.cpp"
click node_led "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/Led.cpp"
click node_button "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/PushButton.cpp"
click node_buzzer "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/Buzzer.cpp"
click node_ldr "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/LDR.cpp"
click node_servo "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/ServoMotor.cpp"
click node_dc_motor "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/DCMotor.cpp"
click node_stepper "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/StepperMotor.cpp"
click node_lcd "https://github.com/faroub/tahakomavrlib/blob/master/lib/component/LCD.cpp"
click node_mcu "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/MCU.cpp"
click node_adc "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/ADC.cpp"
click node_interrupts "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/ExternInterrupt.cpp"
click node_timer "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter.h"
click node_timer0 "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter0.cpp"
click node_timer1 "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter1.cpp"
click node_timer2 "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter2.cpp"
click node_watchdog "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/WatchdogTimer.cpp"
click node_comparator "https://github.com/faroub/tahakomavrlib/blob/master/lib/core/AnalogComparator.h"
click node_pin "https://github.com/faroub/tahakomavrlib/blob/master/lib/io/Pin.cpp"
click node_usart "https://github.com/faroub/tahakomavrlib/blob/master/lib/io/USART0.cpp"
click node_spi "https://github.com/faroub/tahakomavrlib/blob/master/lib/io/SPI.cpp"
click node_chip_config "https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/ha_m328p.h"
click node_base "https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/ha_base.h"
click node_pitch_data "https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/buzzer_pitches_16bit.h"
click node_utils "https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/utils_m328p.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_blink,node_lightmeter,node_musicbox,node_organ toneBlue
class node_led,node_button,node_buzzer,node_ldr,node_servo,node_dc_motor,node_stepper,node_lcd toneAmber
class node_mcu,node_adc,node_interrupts,node_timer,node_timer0,node_timer1,node_timer2,node_watchdog,node_comparator toneMint
class node_pin,node_usart,node_spi,node_chip_config,node_base,node_pitch_data,node_utils toneRose
class node_developer,node_avr toneIndigo
```

## Components

### Example applications

- [LED blink](https://github.com/faroub/tahakomavrlib/blob/master/applications/BlinkLed/main.cpp): `applications/BlinkLed/main.cpp`
- [Light meter](https://github.com/faroub/tahakomavrlib/blob/master/applications/LightMeter/main.cpp): `applications/LightMeter/main.cpp`
- [Music box](https://github.com/faroub/tahakomavrlib/blob/master/applications/MusicBox/main.cpp): `applications/MusicBox/main.cpp`
- [Square-wave organ](https://github.com/faroub/tahakomavrlib/blob/master/applications/Organ/main.cpp): `applications/Organ/main.cpp`

### External components

- [LED control](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/Led.cpp): `lib/component/Led.cpp`
- [Push button](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/PushButton.cpp): `lib/component/PushButton.cpp`
- [Buzzer](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/Buzzer.cpp): `lib/component/Buzzer.cpp`
- [Light sensor](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/LDR.cpp): `lib/component/LDR.cpp`
- [Servo motor](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/ServoMotor.cpp): `lib/component/ServoMotor.cpp`
- [DC motor](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/DCMotor.cpp): `lib/component/DCMotor.cpp`
- [Stepper motor](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/StepperMotor.cpp): `lib/component/StepperMotor.cpp`
- [LCD](https://github.com/faroub/tahakomavrlib/blob/master/lib/component/LCD.cpp): `lib/component/LCD.cpp`

### MCU peripherals

- [MCU control](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/MCU.cpp): `lib/core/MCU.cpp`
- [ADC](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/ADC.cpp): `lib/core/ADC.cpp`
- [External interrupts](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/ExternInterrupt.cpp): `lib/core/ExternInterrupt.cpp`
- [Timer interface](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter.h): `lib/core/TimerCounter.h`
- [Timer counter 0](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter0.cpp): `lib/core/TimerCounter0.cpp`
- [Timer counter 1](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter1.cpp): `lib/core/TimerCounter1.cpp`
- [Timer counter 2](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/TimerCounter2.cpp): `lib/core/TimerCounter2.cpp`
- [Watchdog timer](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/WatchdogTimer.cpp): `lib/core/WatchdogTimer.cpp`
- [Analog comparator](https://github.com/faroub/tahakomavrlib/blob/master/lib/core/AnalogComparator.h): `lib/core/AnalogComparator.h`

### I/O and support

- [GPIO pins](https://github.com/faroub/tahakomavrlib/blob/master/lib/io/Pin.cpp): `lib/io/Pin.cpp`
- [USART0](https://github.com/faroub/tahakomavrlib/blob/master/lib/io/USART0.cpp): `lib/io/USART0.cpp`
- [SPI](https://github.com/faroub/tahakomavrlib/blob/master/lib/io/SPI.cpp): `lib/io/SPI.cpp`
- [ATmega328P definitions](https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/ha_m328p.h): `lib/utils/ha_m328p.h`
- [AVR base support](https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/ha_base.h): `lib/utils/ha_base.h`
- [Buzzer pitch tables](https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/buzzer_pitches_16bit.h): `lib/utils/buzzer_pitches_16bit.h`
- [MCU utilities](https://github.com/faroub/tahakomavrlib/blob/master/lib/utils/utils_m328p.cpp): `lib/utils/utils_m328p.cpp`

### Other components

- **Programmer**
- **AVR microcontroller**

## Connections

- Programmer → LED blink: runs example (evidence: `README.md`)
- Programmer → Light meter: runs example (evidence: `README.md`)
- Programmer → Music box: runs example (evidence: `README.md`)
- Programmer → Square-wave organ: runs example (evidence: `README.md`)
- LED blink → LED control: controls LED (evidence: `applications/BlinkLed/main.cpp`)
- Light meter → LED control: controls LED (evidence: `applications/LightMeter/main.cpp`)
- Light meter → Light sensor: reads light (evidence: `applications/LightMeter/main.cpp`)
- Light meter → ADC: samples input (evidence: `applications/LightMeter/main.cpp`)
- Music box → Buzzer: plays tones (evidence: `applications/MusicBox/main.cpp`)
- Music box → Push button: reads presses (evidence: `applications/MusicBox/main.cpp`)
- Music box → Buzzer pitch tables: uses pitches (evidence: `applications/MusicBox/main.cpp`)
- Square-wave organ → Buzzer: plays tones (evidence: `applications/Organ/main.cpp`)
- Square-wave organ → USART0: uses serial (evidence: `applications/Organ/main.cpp`)
- Square-wave organ → Buzzer pitch tables: uses pitches (evidence: `applications/Organ/main.cpp`)
- LED control → GPIO pins: uses pin
- Push button → GPIO pins: uses pin
- Buzzer → GPIO pins: uses pin
- Buzzer → Timer interface: configures timer
- Light sensor → GPIO pins: uses pin
- Light sensor → ADC: uses converter
- Servo motor → GPIO pins: uses pin
- Servo motor → Timer counter 1: configures timer
- DC motor → GPIO pins: uses pin
- DC motor → Timer counter 0: uses timer
- Stepper motor → GPIO pins: uses pin
- Timer counter 0 → Timer interface: implements interface
- Timer counter 1 → Timer interface: implements interface
- Timer counter 2 → Timer interface: implements interface
- ADC → GPIO pins: uses pin
- External interrupts → Push button: references input
- External interrupts → LED control: references output
- SPI → GPIO pins: uses pin
- MCU control → AVR microcontroller: controls hardware
- GPIO pins → AVR microcontroller: accesses registers
- USART0 → AVR microcontroller: uses peripheral
- SPI → AVR microcontroller: uses peripheral
- AVR base support → ATmega328P definitions: includes definitions (evidence: `lib/utils/ha_base.h`)
- AVR base support → MCU utilities: includes utilities (evidence: `lib/utils/ha_base.h`)
