Reduino transpiles Python scripts into efficient Arduino C++ and uploads automatically. A simple, intuitive way to control sensors, LEDs, and actuators without touching C++.
Project description
Reduino
Write expressive Python that turns into Arduino-flavoured C++ and optional PlatformIO projects. Reduino lets you describe LED-centric sketches with familiar control flow, transpiles the script into Arduino code, and (optionally) compiles/uploads it for you.
Table of contents
- Quick start
- How Reduino works
- Supported devices & primitives
- Supported Python features
- Testing
- Contributing
- License
Quick start
- Install dependencies
pip install -e . pip install platformio # required for uploads
- Create a script
from Reduino import target from Reduino.Actuators import Led from Reduino.Time import Sleep target("/dev/ttyACM0", upload=False) led = Led(13) for _ in range(3): led.toggle() Sleep(250) while True: led.toggle() Sleep(500)
- Run the script – the transpiled C++ is printed and written into a temporary
PlatformIO project. If
upload=True, Reduino also callspio run -t uploadfor you.
Generated projects target an Arduino Uno by default and live in a temporary folder. You can
re-run pio run manually to rebuild or flash again.
How Reduino works
- Parsing –
Reduino.transpile.parser.parse()reads your Python script and builds an intermediate representation (Program,LedDecl,Sleep, etc.). - Analysis – literals and expressions are folded where possible (for example constant
arithmetic or tuple unpacking), and control structures like
if/elif/elseare preserved in the IR. - Emission –
Reduino.transpile.emitter.emit()turns the IR into Arduino-ready C++. Pin declarations createpinModecalls and global state, and sleep nodes becomedelay()statements. - Toolchain integration –
Reduino.target()callsemit(parse(src)), prints the result, and uses the PlatformIO helpers inReduino.toolchain.pioto write amain.cppplusplatformio.inipointing at the requested serial port.
The pipeline keeps parsing/emission side-effect free so your host machine never drives hardware directly—hardware interaction only happens once the generated sketch runs on the board.
Supported devices & primitives
| Primitive | Description | Key operations |
|---|---|---|
Reduino.Actuators.Led(pin=13) |
Represents a digital output LED. The helper mirrors the generated C++ and is safe to use in tests. | .on(), .off(), .toggle(), .get_state() |
Reduino.Time.Sleep(ms) |
Millisecond delay helper that can also execute waits on the host side. | .wait(), callable shortcut (e.g. Sleep(500)()) |
Reduino.target(port, upload=True) |
Transpile the calling module, emit C++, and optionally compile/upload with PlatformIO. | Prints generated code, writes a project, triggers pio run/pio run -t upload |
Supported Python features
Reduino focuses on a lightweight DSL that feels like idiomatic Python while staying safe for static analysis.
Control flow
while True:blocks become the Arduinoloop()body.for i in range(N):loops at top-level unroll into repeated setup statements.if/elif/elseconstructs are preserved with their conditions.
Variables & assignments
- Regular assignments, tuple unpacking, and reassignments in setup scope create matching C++ declarations.
- Branch-local assignments are promoted to globals so both sides of an
ifcan mutate them safely.
Expressions & built-ins
- Integer, float, string, and boolean literals.
- Arithmetic, bitwise, boolean, and comparison operators.
- Safe casts:
int(),float(),bool(),str(). - Built-ins:
len(),abs(),max(),min()(with helper snippets emitted automatically).
Device primitives
- Instantiate LEDs with literal pins or symbolic expressions; actions translate to
digitalWritecalls (HIGH,LOW, and toggled states are handled automatically). - Sleep expressions become
delay(ms)even when the argument is symbolic.
Target directive
target("PORT")can appear anywhere at top level; the last call wins and is written intoplatformio.ini.
Testing
Install the optional development dependencies and run the test suite:
pip install -e .[dev]
pytest
The tests exercise parser behaviour, code generation, runtime helpers, and the public actuator/time primitives.
Contributing
We welcome new actuators, sensors, and improvements to the transpiler. See CONTRIBUTING.md for a detailed guide.
License
Reduino is released under the GNU General Public License v3.0 (GPL-3.0).
This means you are free to:
- Use, modify, and distribute Reduino under the terms of the GPL-3.0.
- Build upon it in your own open-source projects, provided your derivative works remain open-source under the same license.
However, if you would like to:
- Use Reduino in a closed-source, commercial, or proprietary product,
- Obtain a custom or dual license for integration in commercial environments,
please reach out for licensing options:
📧 Commercial inquiries: arnavbajaj9@gmail.com
© 2025 Arnav Bajaj. All rights reserved.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reduino-0.0.2.tar.gz.
File metadata
- Download URL: reduino-0.0.2.tar.gz
- Upload date:
- Size: 43.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bb73d7c25c894732d1e7fce2c187228a40bc7f5e40a2bc5d06da7bb300e724f
|
|
| MD5 |
0a402b6a065f96b774aec3acfd296758
|
|
| BLAKE2b-256 |
a233086ab8e7b94c554fb4a35ab9b21c2eb0b63c8a550b7e3bcf5f674e4c572b
|
File details
Details for the file reduino-0.0.2-py3-none-any.whl.
File metadata
- Download URL: reduino-0.0.2-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89298fc4f49cdfec842de21239ee479ff03967f0b85eb45f7f6f332d831a3c54
|
|
| MD5 |
fa699d993b98692cbb6f0d8d402b318e
|
|
| BLAKE2b-256 |
7cbb685c99b77ab4b7655fc71205ba8aa6ce25dd03be249c79e5e95247dfbef2
|