SkillAgentSearch skills...

Reduino

Write Arduino code in pure Python. Reduino transpiles Python scripts into efficient Arduino C++ and uploads automatically. A simple, intuitive way to control sensors, LEDs, and actuators without touching C++.

Install / Use

/learn @Jackhammer9/Reduino

README

<div align="center"> <img src="https://raw.githubusercontent.com/Jackhammer9/Reduino/refs/heads/main/.github/workflows/Reduino.png" alt="Reduino" width="360" /> <h1>Reduino</h1> <p><em>Write friendly Python. Get Arduino-ready C++. Upload Easily to MCUs.</em></p> <a href="https://www.buymeacoffee.com/Jackhammer"> <img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" height="45" /> </a> <br> <br> <a href="https://www.gnu.org/licenses/gpl-3.0"> <img alt="License" src="https://img.shields.io/badge/License-GPLv3-blueviolet" /> </a> <a href="https://github.com/Jackhammer9/Reduino/stargazers"> <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/Jackhammer9/Reduino?logo=Github" /> </a> <a href="https://github.com/Jackhammer9/Reduino/network/members"> <img alt="GitHub forks" src="https://img.shields.io/github/forks/Jackhammer9/Reduino?color=red&logo=Github&style=flat-square" /> </a> <a href="https://github.com/Jackhammer9/Reduino/watchers"> <img alt="GitHub watchers" src="https://img.shields.io/github/watchers/Jackhammer9/Reduino?logo=Github" /> </a> <a href="https://github.com/Jackhammer9"> <img alt="GitHub followers" src="https://img.shields.io/github/followers/Jackhammer9?logo=Github" /> </a> <a href="https://github.com/Jackhammer9/Reduino/pulls?q=is%3Apr+is%3Aclosed"> <img alt="Closed PRs" src="https://img.shields.io/github/issues-pr-closed/Jackhammer9/Reduino?logo=Github" /> </a> <a href="https://github.com/Jackhammer9/Reduino/issues?q=is%3Aissue+is%3Aclosed"> <img alt="Closed issues" src="https://img.shields.io/github/issues-closed/Jackhammer9/Reduino?logo=Github" /> </a> <a href="https://github.com/Jackhammer9/Reduino"> <img alt="Repo size" src="https://img.shields.io/github/repo-size/Jackhammer9/Reduino?logo=Github" /> </a> <a href="https://github.com/Jackhammer9/Reduino/releases/latest"> <img alt="Latest release" src="https://img.shields.io/github/v/release/Jackhammer9/Reduino?display_name=tag&logo=Github" /> </a> <a href="https://pypi.org/project/Reduino/"> <img alt="PyPI version" src="https://img.shields.io/pypi/v/Reduino?logo=pypi" /> </a> <a href="https://pypistats.org/packages/reduino"> <img alt="PyPI downloads" src="https://img.shields.io/pypi/dm/Reduino?label=PyPI%20downloads&logo=pypi" /> </a> <img alt="Python Lines Of Code" src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Jackhammer9/221805154809373180108ca1d24ddccd/raw/python-loc.json" /> </div>

Table of contents


Overview

Reduino lets you write high-level Python that compiles into clean Arduino C++, then optionally uploads it to your board via PlatformIO.


Quick start

pip install Reduino
pip install platformio  # required for automatic uploads

[!NOTE] PlatformIO is only required for automatic build & upload. You can still transpile without it.


The target() function (Required)

Place target() at the very top of your script, immediately after imports. This is the entry point that tells Reduino to parse your entire file, transpile it to Arduino C++, and (optionally) upload it.

| Parameter | Type | Default | Description | | ---------: | :----: | :----------: | --------------------------------------------------------------------------- | | port | str | — | Serial port, e.g. "COM3" or "/dev/ttyACM0". | | upload | bool | True | If True, compile & upload via PlatformIO. If False, only transpile. | | platform | str | "atmelavr" | PlatformIO platform ID. Reduino currently supports atmelavr and atmelmegaavr. | | board | str | "uno" | PlatformIO board ID. Must be compatible with platform. |

Returns: str of the generated Arduino C++ source.

Minimal example (top-of-file target)

from Reduino import target
target("COM3")  # upload=True by default

# Your Reduino code below...

Example: Reduino structure explained

Reduino automatically splits your Python code into Arduino sections.

from Reduino import target
target("COM3")

from Reduino.Actuators import Led
led = Led(13)

while True:
    led.toggle()          # repeated code -> goes into void loop()

Generated Arduino structure (conceptually):

void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, !digitalRead(13));
  delay(500);
}

Everything before while True: (declarations, prints, sensor setup, etc.) is placed inside setup(), and everything inside the while True loop is placed in loop().

Transpile only (no upload)

from Reduino import target
cpp = target("COM3", upload=False)
print(cpp)

# Your Reduino code below...

Targeting different platforms & boards

Reduino validates that the requested PlatformIO platform/board pair is supported. At the moment two PlatformIO platforms are available:

  • atmelavr – classic AVR-based boards (Uno, Nano, Leonardo, etc.).
  • atmelmegaavr – newer megaAVR devices (Nano Every, Uno WiFi Rev2, Curiosity Nano kits, ...).

Every board listed in the PlatformIO board registry for all platforms can be targeted. If you choose an unsupported board, or one that does not belong to the selected platform, target() raises a ValueError with a helpful message.

from Reduino import target

# Build for an Arduino Nano Every without uploading automatically.
target(
    "COM9",
    upload=False,
    platform="atmelmegaavr",
    board="nano_every",
)

# Build for a classic Arduino Uno and upload immediately.
target("/dev/ttyUSB0", platform="atmelavr", board="uno")

[!IMPORTANT] target() reads the whole file text and generates code for everything below it. If upload=True, it also builds and flashes using a temporary PlatformIO project.


API reference

Actuators

LED

| Method | Description | | ---------------------------------------------------------------- | --------------------------------- | | Led(pin=13) | Bind an LED to a digital/PWM pin. | | on() / off() | Turn fully on/off. | | toggle() | Flip state. | | get_state() | True if on. | | get_brightness() / set_brightness(v) | PWM 0–255. | | blink(duration_ms, times=1) | Blink helper. | | fade_in(step=5, delay_ms=10) / fade_out(step=5, delay_ms=10) | Smooth ramp. | | flash_pattern(pattern, delay_ms=200) | Run pattern of 0 & 1s eg: [1,0,0,1,1,1]. |

Example

from Reduino import target
target("COM3")

from Reduino.Actuators import Led
from Reduino.Utils import sleep

led = Led(9)
led.set_brightness(128)
led.blink(200, times=3)
sleep(500)
led.off()

RGB LED

| Method | Description | | --------------------------------------- | --------------------------- | | RGBLed(r_pin, g_pin, b_pin) | Bind RGB to three PWM pins. | | set_color(r,g,b) | Set color (0–255 each). | | on(r=255,g=255,b=255) / off() | White / off. | | fade(r,g,b,duration_ms=1000,steps=50) | Transition to target color. | | blink(r,g,b,times=1,delay_ms=200) | Blink with color. |

Example

from Reduino import target
target("COM3")

from Reduino.Actuators import RGBLed
from Reduino.Utils import sleep

rgb = RGBLed(9, 10, 11)
rgb.set_color(0, 128, 255)
rgb.fade(255, 0, 0, duration_ms=1500)
sleep(300)
rgb.off()

Buzzer

| Method | Description | | ------------------------------------------------------ | --------------------- | | Buzzer(pin=8, default_frequency=440.0) | Create buzzer. | | play_tone(frequency, duration_ms=None) | Play tone. | | stop() | Stop sound. | | beep(frequency=None, on_ms=100, off_ms=100, times=1) | Repeated tone. | | sweep(start_hz, end_hz, duration_ms, steps=10) | Sweep frequencies. | | melody(name, tempo=None) | Play built-in melody. |

Built-in melodies: success, error, startup, notify, alarm, scale_c, siren

Example

from Reduino import target
target("COM3")

from Reduino.Actuators import Buzzer
from Reduino.Utils import sleep

bz = Buzzer(8)
bz.melody("startup")
sleep(500)
bz.beep(frequency=880, on_ms=100, off_ms=100, times=3)
bz.stop()

Servo

| Method

Related Skills

View on GitHub
GitHub Stars134
CategoryDevelopment
Updated5d ago
Forks7

Languages

Python

Security Score

100/100

Audited on Mar 20, 2026

No findings