Skip to main content

Arduino-style motor control using Firmata

Project description

motor-like-arduino

Arduino-style DC motor control for Python.

Control motors connected to an Arduino running StandardFirmata using simple, intuitive commands inspired by the Arduino ecosystem.

from motor_like_arduino import Board

board = Board("/dev/ttyUSB0")

motor = board.attach_motor(2, 4, 11)

motor.forward(100)

Why motor-like-arduino?

Most Python motor libraries expose low-level motor driver details.

motor-like-arduino focuses on simplicity:

motor.forward(100)
motor.backward(50)
motor.stop()
motor.brake()

No PWM calculations.

No complicated setup.

Just simple motor control.


Installation

pip install motor-like-arduino

Quick Start

from motor_like_arduino import Board
import time

board = Board("/dev/ttyUSB0")

motor = board.attach_motor(
    2,  # Direction Pin 1
    4,  # Direction Pin 2
    11  # PWM Pin
)

motor.forward(100)

time.sleep(2)

motor.stop()

board.close()

Multiple Motors

from motor_like_arduino import Board

board = Board("/dev/ttyUSB0")

left_motor = board.attach_motor(
    2,
    4,
    11
)

right_motor = board.attach_motor(
    5,
    3,
    10
)

left_motor.forward(50)
right_motor.forward(100)

Features

  • Simple Arduino-inspired API
  • Percentage-based speed control (0-100)
  • Forward and backward movement
  • Stop and brake support
  • Multiple motors per board
  • Optional TB6612FNG standby support
  • Automatic speed validation
  • Safe board shutdown
  • Context manager support
  • Custom exceptions
  • Built on top of pyFirmata2

Supported Motor Drivers

Any motor driver that uses:

  • 2 direction pins
  • 1 PWM pin

Including:

  • TB6612FNG
  • L293D
  • L298N
  • MX1508

Optional TB6612FNG Standby Support

board = Board(
    "/dev/ttyUSB0",
    stby=6
)
board.sleep()
board.wake()

Included Examples

The repository includes ready-to-run examples:

  • Single Motor Control
  • Dual Motor Control
  • Tank Drive
  • Keyboard Control

Documentation

Complete documentation, API reference, guides, and examples are available in the project wiki.


Requirements

  • Python 3.8+
  • Arduino running StandardFirmata

Author

Vihaan Parlikar


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

motor_like_arduino-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

motor_like_arduino-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file motor_like_arduino-0.1.0.tar.gz.

File metadata

  • Download URL: motor_like_arduino-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for motor_like_arduino-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a8400b04e35060d1bd9ee5b0aa0120b1e60cb5dd98c0fb6a50e7b04550112249
MD5 139a09544c9f603d8fe8c9006b0e0c7b
BLAKE2b-256 a3ad118a6ca9320d36822e45b9f0eda12212d3eb927be2f05cbeaa97c1d27773

See more details on using hashes here.

Provenance

The following attestation bundles were made for motor_like_arduino-0.1.0.tar.gz:

Publisher: publish.yml on vihaanvp/motor-like-arduino

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file motor_like_arduino-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for motor_like_arduino-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5812141c54566bd9e0ba86405c6360d5ed01fda4c78714c111c10943a35de932
MD5 317efdb88349af4fd934fa1bc792b2d3
BLAKE2b-256 16cb64c339783c2ab2f8c3fa60bf2e271c98c401118151ad3dc8e88d0c0cba49

See more details on using hashes here.

Provenance

The following attestation bundles were made for motor_like_arduino-0.1.0-py3-none-any.whl:

Publisher: publish.yml on vihaanvp/motor-like-arduino

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page