mcpField
A
arduino-code-generator

arduino-code-generator

github.com/wedsamuel1230Development29403 installsUpdated 3w ago
Repository

About arduino-code-generator

arduino-code-generator is a skill for generating Arduino code snippets across common embedded patterns. It includes board-specific templates, examples, and guidance for checking build and hardware evidence.

Key features

  1. 01Generate snippets from nine pattern templates
  2. 02Support UNO, ESP32, and RP2040
  3. 03Cover sensors, inputs, communication, and timing
  4. 04Provide example sketches and wiring guides
  5. 05Check compilation and board constraints

Use cases

  1. 01Create an I2C sketch for ESP32
  2. 02Add button debouncing to an Arduino project
  3. 03Build non-blocking schedules or state machines
  4. 04Log sensor data to EEPROM or SD

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/wedsamuel1230/arduino-skills --skill arduino-code-generator

After installing, type/arduino-code-generatorin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

assets/
workflow.mmd
examples/
buttons-example.ino
config-example.ino
csv-example.ino
data-logging-example.ino
filtering-example.ino
hardware-detection-example.ino
i2c-example.ino
README.md
scheduler-example.ino
state-machine-example.ino
references/
patterns-buttons.md
patterns-config.md
patterns-csv.md
patterns-data-logging.md
patterns-filtering.md
patterns-hardware-detection.md
patterns-i2c.md
patterns-scheduler.md
patterns-state-machine.md
README.md
rules/
board-optimization.md
common-pitfalls.md
quality-standards.md
scripts/
generate_snippet.py
verify_patterns.ps1
verify_patterns.sh
templates/
code-output-template.md
workflow/
step1-identify-pattern.md
step2-read-reference.md

Details

From the project README

Arduino Code Generator

Generate production-quality Arduino code snippets for sensors, actuators, communication, and embedded patterns.

Quick Start

Browse example sketches:

# See 9 production-ready examples in examples/ folder
ls examples/
# config-example.ino, filtering-example.ino, buttons-example.ino,
# i2c-example.ino, csv-example.ino, scheduler-example.ino,
# state-machine-example.ino, hardware-detection-example.ino,
# data-logging-example.ino

List available patterns:

uv run --no-project scripts/generate_snippet.py --list

Generate code for specific pattern and board:

uv run --no-project scripts/generate_snippet.py --pattern i2c --board esp32
uv run --no-project scripts/generate_snippet.py --pattern buttons --board uno --output button.ino

Interactive mode:

uv run --no-project scripts/generate_snippet.py --interactive

Target Gate

Read the shared contract and the board profile before selecting pins, APIs, or libraries. Keep board-specific branches isolated, check memory and peripheral constraints, and state whether the result has build proof only or also has upload, hardware, and system proof. The generator's board flag is a template selector, not evidence that the generated code works on a similar-looking board.

Resources

  • examples/ - 9 production-ready example sketches (one per pattern category)
  • examples/README.md - Detailed documentation for each example with wiring diagrams
  • scripts/generate_snippet.py - CLI tool for code generation with 9 pattern templates
  • scripts/verify_patterns.ps1 - Compile examples for UNO/ESP32/RP2040 (PowerShell)
  • scripts/verify_patterns.sh - Compile examples for UNO/ESP32/RP2040 (bash)
  • assets/workflow.mmd - Mermaid diagram of code generation workflow

Supported Patterns

Hardware Abstraction
  • Multi-board config.h with conditional compilation
  • Pin definitions for UNO/ESP32/RP2040
  • Memory budget tracking

See patterns-config.md | Example: config-example.ino

Sensor Reading & Filtering
  • ADC noise reduction (moving average, median, Kalman)
  • DHT22, BME280, analog sensors
  • Data validation and calibration

See patterns-filtering.md | Example: filtering-example.ino

Input Handling
  • Software button debouncing
  • Edge detection (PRESSED/RELEASED/LONG_PRESS)
  • Multi-button management

See patterns-buttons.md | Example: buttons-example.ino

Communication
  • I2C device scanning and diagnostics
  • SPI configuration
  • UART/Serial protocols
  • CSV data output

See patterns-i2c.md and patterns-csv.md | Examples: i2c-example.ino, csv-example.ino

Timing & Concurrency
  • Non-blocking millis() patterns
  • Task scheduling without delay()
  • Priority-based schedulers
  • State machines

See patterns-scheduler.md and patterns-state-machine.md | Examples: scheduler-example.ino, state-machine-example.ino

Hardware Detection
  • Auto-detect boards (UNO/ESP32/RP2040)
  • SRAM usage monitoring
  • Sensor fallback strategies
  • Adaptive configuration

See patterns-hardware-detection.md | Example: hardware-detection-example.ino

Data Persistence
  • EEPROM with CRC validation
  • SD card FAT32 logging
  • Wear leveling for EEPROM
  • Buffered writes

See patterns-data-logging.md | Example: data-logging-example.ino

Code Generation Workflow

Quality Standards & Rules

Code Output Template

  • Code Template - Standardized structure for generated Arduino sketches

Resources

  • examples/ - 9 production-ready example sketches (one per pattern category)
  • examples/README.md - Detailed documentation for each example with wiring diagrams
  • scripts/generate_snippet.py - CLI tool for code generation with 9 pattern templates
  • assets/workflow.mmd - Mermaid diagram of code generation workflow
  • workflow/ - Step-by-step code generation process
  • rules/ - Quality standards and board-specific optimizations
  • templates/ - Code output templates and structure guidelines
  • references/ - Detailed pattern documentation and API references
  • references/README.md - Reference structure and formatting guide

Shared Output Contract

Use the shared Arduino skill contract: state assumptions, required tools and versions, implementation steps, tests/evidence by proof stage, known limitations, and recovery/security notes.

Comments

Markdown supported