Arduino-style motor and servo control using Firmata — a combined MegaWrapper library
Reason this release was yanked:
Wrong version tag
Project description
MegaWrapper
A combined DC-motor + servo control library for Arduino via Firmata.
from megawrapper import Board
board = Board("/dev/ttyUSB0")
motor = board.attach_motor(2, 4, 11)
motor.forward(100)
board.close()
Installation
pip install -e /path/to/MegaWrapper
Requires Python 3.8+. Primary dependency: pyfirmata2. Optional: pyserial (for the alternative Firmata backend), adafruit-circuitpython-vl53l0x (for the ToF sensor).
Documentation
Full API reference, wiring diagrams, and usage guides are on the project wiki.
Examples
Ready-to-run scripts are in examples/:
| File | What it shows |
|---|---|
single_motor.py |
Basic motor forward/stop |
dual_motor.py |
Two motors with names |
tank_drive.py |
Differential steering pattern |
keyboard_control.py |
Interactive CLI motor control |
endless_sweep.py |
Servo sweep via sweep() |
move_smooth.py |
Servo motion with move_smooth() |
pyserial_control.py |
Using the pyserial Firmata backend |
vl53l0x_sensor.py |
VL53L0X distance sensor readout |
Run any example with python examples/<file>.py.
API Overview
Board
Board(port, stby=None) # Connect to Arduino (stby = optional STBY pin)
Board.get_active_board() # Get the most recently created Board
Board.has_active_board() # True if any Board is active
board.attach_motor(d1, d2, pwm, name=None)
board.stop_all()
board.wake() / board.sleep() # Requires stby pin
board.close() # Stop motors + release board
Motor
motor.forward(speed) # 0–100
motor.backward(speed) # 0–100
motor.stop() # Coast stop
motor.brake() # Active brake
motor.set_speed(n) # Change speed without changing direction
motor.speed # Current speed (0–100)
motor.direction # "forward" | "backward" | "stopped" | "braked"
Servo
servo = Servo()
servo.attach(pin) # Must create a Board first
servo.write(angle) # 0–180 (clamped)
servo.read() # Returns last commanded angle
servo.move_smooth(target, delay_ms=15)
servo.sweep(start=0, end=180, step=1, delay_ms=15)
servo.detach()
Utilities
delay(ms) # Blocking sleep in milliseconds
millis() # Monotonic millisecond counter
Backend Modes
set_mode("pyserial") # Use built-in pyserial Firmata client
set_mode("pyfirmata2") # Default — use pyfirmata2 library
get_mode() # Current mode
Exceptions
MegaWrapperError, InvalidSpeedError, BoardConnectionError, StandbyNotConfiguredError
Testing
python -m pytest tests/ -v
All tests mock the Arduino — no hardware required. 92 tests, ~0.5 s.
License
MIT
Project details
Release history Release notifications | RSS feed
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 megawrapper-1.0.0.tar.gz.
File metadata
- Download URL: megawrapper-1.0.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0134a5d55dca754e97ba540d8db436782d2f900f50d01d175e1d227ebcc02895
|
|
| MD5 |
eac83cfdac522c57968fdce7dfeac256
|
|
| BLAKE2b-256 |
eb417d3856b3d36030835c43ceb1e1e17ecbcd96a51255a1e96ce52c9dd429a6
|
Provenance
The following attestation bundles were made for megawrapper-1.0.0.tar.gz:
Publisher:
publish.yml on vihaanvp/MegaWrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megawrapper-1.0.0.tar.gz -
Subject digest:
0134a5d55dca754e97ba540d8db436782d2f900f50d01d175e1d227ebcc02895 - Sigstore transparency entry: 2065801871
- Sigstore integration time:
-
Permalink:
vihaanvp/MegaWrapper@26ab18a78a9af06c6f26feb3c27d70a588070fdb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/vihaanvp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26ab18a78a9af06c6f26feb3c27d70a588070fdb -
Trigger Event:
release
-
Statement type:
File details
Details for the file megawrapper-1.0.0-py3-none-any.whl.
File metadata
- Download URL: megawrapper-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
353a3889b6a159d21dc09b5f200f26a09df72b7afeb5aab0a4b5f55ce72d0c3b
|
|
| MD5 |
850a78eee9ca018d07463f5a19a50bdd
|
|
| BLAKE2b-256 |
c17fbdedf68b78a0ab8e0982e5109fc54c0766ed30fd15867eb112f3fa0906fe
|
Provenance
The following attestation bundles were made for megawrapper-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on vihaanvp/MegaWrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
megawrapper-1.0.0-py3-none-any.whl -
Subject digest:
353a3889b6a159d21dc09b5f200f26a09df72b7afeb5aab0a4b5f55ce72d0c3b - Sigstore transparency entry: 2065802180
- Sigstore integration time:
-
Permalink:
vihaanvp/MegaWrapper@26ab18a78a9af06c6f26feb3c27d70a588070fdb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/vihaanvp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26ab18a78a9af06c6f26feb3c27d70a588070fdb -
Trigger Event:
release
-
Statement type: