Skip to main content

A MicroPython driver for the L9110 motor controller over I2C

Project description

Describe

A MicroPython package to control the L9110 motor driver over I2C.

Installation

How to use mke_m17_micropython lib

1. Initialize the Driver

Create an L9110 instance to control your device.

Parameters:

  • address (int): The I2C address of the L9110 chip. Default is 0x40.
  • bus (I2C): A pre-initialized machine.I2C object (optional). If not provided, a default I2C bus is used.
  • bus_number (int): The I2C bus number (default is 1). Ignored if bus is provided.

Example:

from machine import I2C, Pin
from L9110_I2C import L9110

# Default settings (bus_number=1)
l9110 = L9110()

# Custom I2C bus (e.g., for ESP32)
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
l9110 = L9110(address=0x42, bus=i2c)

# With context manager
with L9110(address=0x42, bus=i2c) as l9110:
    pass

2. Control Servos

Use control_servo() to set servo angles.

Args:

  • servo_id (int): 1 (S1) or 2 (S2).
  • degree (int): Angle in degrees (default: 0-180).

Returns:

True on success, False on failure.

Example:

l9110.control_servo(1, 150)  # Servo 1 to 150°
l9110.control_servo(2, 90)   # Servo 2 to 90°

3. Control DC Motors

Use control_motor() to set motor speed and direction.

Args:

  • motor_id (int): 0 (MA) or 1 (MB).
  • percent (float): Speed as a percentage (0-100).
  • direction (int): 0 (CW) for clockwise, 1 (CCW) for counterclockwise.

Returns:

True on success, False on failure.

Example:

l9110.control_motor(0, 50, 0)  # Motor A, 50%, clockwise
l9110.control_motor(1, 70, 1)  # Motor B, 70%, counterclockwise

4. Change I2C Address

Update the device’s I2C address with set_address().

Args:

  • new_address (byte): New address (0x40-0x44).

Returns:

True on success, False on failure.

Example:

l9110.set_address(0x42)
# Output: "Set address successful. New address: 0x42"

5. Customize Servo Range

Set new range degree.

using set_range_degree(min_degree, max_degree) to set new range degree for servo motor

Args:

  • min_degree(int): (0-359).
  • max_degree(int): (1-360).

Example:

l9110.set_range_degree(0, 270)

Set new range pulse.

using set_range_pulse(min_pulse, max_pulse) to set new range degree for servo motor

Args:

  • min_pulse(int): (0-2814).
  • max_pulse(int): (1-2815).

Example:

l9110.set_range_pulse(600, 2400)

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

mke_m17_micropython-0.1.4.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

mke_m17_micropython-0.1.4-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file mke_m17_micropython-0.1.4.tar.gz.

File metadata

  • Download URL: mke_m17_micropython-0.1.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for mke_m17_micropython-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9dd37fb93be85a89326777c66b0c54a112af54156327b0f072c8fce6cda473fe
MD5 0b99d8424106d51fb1f8b87bda592afe
BLAKE2b-256 4c45e81d7d86b61113c609d66cb1259547e6e66c020f88726ba1851e5140b5a3

See more details on using hashes here.

File details

Details for the file mke_m17_micropython-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mke_m17_micropython-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a0604a35209b3dac6991e2410496c4bc089418e6bbb9d31059dd518d8470df87
MD5 c73e679f81678d393c90ec491d4a0bba
BLAKE2b-256 039067d317c8b928621565913da9dcd62f030ec35a1e1f2a9e4084c9f94045a9

See more details on using hashes here.

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