Skip to content
vihaanvp edited this page Jun 25, 2026 · 7 revisions

MegaWrapper

Version: 1.0.0
Author: Vihaan Parlikar
License: MIT

A unified Python library for Arduino-style DC motor and servo control over Firmata. Wraps pyfirmata2 to give you a simple, Arduino-inspired API.


Quick Links

Page Description
Board API Board class, connection, motor management, standby pin
Motor API DC motor control — forward, backward, stop, brake
Servo API Servo control — write, read, smooth movement, sweep
Utilities delay(), millis() helpers
Exceptions Exception hierarchy and catch-all patterns
Examples 10 complete runnable examples
Edge Cases & Notes Behavioural details and gotchas

Installation

# Required dependencies
pip install pyfirmata2 pyserial

# Install MegaWrapper (local / editable)
pip install -e /path/to/MegaWrapper

# Or just point pip at the directory
pip install -e .

Arduino Setup

  1. Open the Arduino IDE.
  2. Go to File → Examples → Firmata → StandardFirmata.
  3. Upload the sketch to your Arduino board.
  4. Leave the USB cable connected — that's the serial link the library uses.

Port Identification

OS Typical port
Linux /dev/ttyUSB0, /dev/ttyACM0
macOS /dev/tty.usbserial-*, /dev/tty.usbmodem*
Windows COM3, COM4, etc.

To find the right port on Windows, open Device Manager and look under Ports (COM & LPT). On Linux/macOS, run ls /dev/tty* before and after plugging in the Arduino and see what appears.


Package Overview

from megawrapper import (
    Board,                     # Arduino connection
    Motor,                     # DC motor (H-bridge)
    Servo,                     # Servo motor
    delay,                     # Pause (ms)
    millis,                    # Epoch time (ms)

    MegaWrapperError,          # Base exception
    InvalidSpeedError,         # Speed out of 0-100
    BoardConnectionError,      # Can't reach Arduino
    StandbyNotConfiguredError, # STBY pin not set

    __version__,               # "1.0.0"
)

All public symbols are importable directly from megawrapper:

from megawrapper import Board, Motor, Servo

Clone this wiki locally