FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

programmersd21/pyduino: Create beautiful .ino (Arduino) sketches with only Python knowledge - no extra skills needed! ๐ŸŒŸ It's effortless, fun and free! ๐Ÿ˜Ž ยท GitHub

Latest commit

ย 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŸ PyDuino - Python to Arduino Bridge ๐ŸŒŸ

PyDuino is a Python-to-Arduino transpiler and uploader. Write Arduino sketches in Python, automatically convert them to C++ .ino files, and upload to your Arduino board.


โšก Features

  • Convert C++ headers to Python stubs (.py) ๐Ÿ“
  • Transpile Python scripts to Arduino .ino files โš™๏ธ
  • Auto-generate setup() and loop() if missing ๐Ÿ”„
  • Upload sketches directly to Arduino from Python ๐Ÿš€
  • Detect Arduino headers in Python files ๐Ÿ”
  • List available COM ports ๐Ÿ“ก
  • Support for multiple function overloads and basic Python-to-C++ expressions โœจ
  • Your comments are retained! ๐Ÿ—ฃ๏ธ

๐Ÿ› ๏ธ Setup Guide

  1. Clone or download the PyDuino repo.
  2. Ensure that Python 3.11+ is installed.
  3. Run build.bat.
  4. Enjoy!
  5. Examples at: https://github.com/pro-grammer-SD/pyduino_seperate_tests/

๐Ÿš€ Commands

1๏ธโƒฃ Create a new project

python main.py create <project_name>

Creates a folder with main.py and lib/ for headers.

2๏ธโƒฃ Convert C++ header to Python stub

python main.py convert-header <header_file> [--libclang <path_to_libclang>] # or you can skip --libclang by default!

Generates Python .py stubs in lib/.

3๏ธโƒฃ Transpile Python to .ino

python main.py to-ino <python_file> [--auto-loop]

Generates .ino file. --auto-loop will call all functions in loop() automatically.

4๏ธโƒฃ Setup Arduino AVR core

python main.py setupavr

Installs the Arduino AVR core using arduino-cli.

5๏ธโƒฃ Upload Python script to Arduino

python main.py upload <python_file> [--auto-loop] [--port <COM>] [--list-ports] [--fqbn <fqbn>]
  • --auto-loop: auto-call functions in loop()
  • --port: specify COM port
  • --list-ports: show available boards
  • --fqbn: Fully Qualified Board Name (default: arduino:avr:uno)

๐Ÿ“ฆ Python-to-C++ Conversion

  • Converts Python for, while, if, and function definitions to Arduino C++.
  • Supports arithmetic, boolean, comparison, and unary operations.
  • Detects headers from from lib.<header> import lines.

๐Ÿ’ก Logging

  • Upload logs are stored in <sketch_dir>/logs/YYYYMMDD_HHMMSS.log

โš™๏ธ Example Workflow

# Create a project
python main.py create MyProject

# Convert a header
python main.py convert-header lib/CheapStepper.h

# Transpile Python to .ino
python main.py to-ino main.py --auto-loop

# List ports
python main.py upload main.py --list-ports

# Upload to board
python main.py upload main.py --port COM3 --fqbn arduino:avr:uno

#๐Ÿ’ก Tip: the port is auto-detected, so generally in normal cases you don't need to specify it. Only use it if you really need to.

๐Ÿ’โ€โ™‚๏ธ Extra Info

  • ๐Ÿ”’ PyDuino currently supports Windows only. It would be great if you could help me to port it to other operating systems.
  • ๐Ÿ˜„ Also, feel free to help me improve this library, block-by-block! PRs are always welcome and openly supported!

Made with ๐Ÿ’œ by @pro-grammer-SD

About

Create beautiful .ino (Arduino) sketches with only Python knowledge - no extra skills needed! ๐ŸŒŸ It's effortless, fun and free! ๐Ÿ˜Ž

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages


Back | FazBrowse Home | New Git URL