Skip to main content

A modern Python library for controlling HiWonder's LX-16A servos

Project description

PyLX-16A

A modern Python library for controlling HiWonder's (previously LewanSoul's) LX-16A servos.

Install and Setup

Simply copy lx16a.py into your project directory.

Don't try to guess the port your controller is connected to. On Linux, run sudo dmesg after plugging it in, which prints the most recent kernel messages. It should say something like ch341-uart converter now attached to ttyUSB0, in which case the port you want is /dev/ttyUSB0.

There's also the possibility that your program doesn't have access to the port you want to use. In this case, we need to modify the permissions of the port (e.g. /dev/ttyUSB0). To make it publicly readable and writable, run sudo chmod a+rw /dev/ttyUSB0.

Documentation

Refer to documentation.md.

Example program

from math import sin, cos, pi
from lx16a import *
import time

LX16A.initialize("/dev/ttyUSB0")

try:
    servo1 = LX16A(1)
    servo2 = LX16A(2)
    servo1.set_angle_limits(0, 240)
    servo2.set_angle_limits(0, 240)
except ServoTimeoutError as e:
    print(f"Servo {e.id_} is not responding. Exiting...")
    quit()

t = 0
while True:
    servo1.move(sin(t) * 60 + 60)
    servo2.move(cos(t) * 60 + 60)

    time.sleep(0.05)
    t += 0.1

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

pylx16a-1.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

pylx16a-1.0.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file pylx16a-1.0.0.tar.gz.

File metadata

  • Download URL: pylx16a-1.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pylx16a-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8e91265ea4098ccaeb0e0a32a161b4c3ed28c99a953b99bafd465629ee3f6c0f
MD5 6a7e545054173205cf7683fbc9faa3cb
BLAKE2b-256 fe60e4b86ca8645425ad62367ffdee7faa0606e0c26944e07ee8f2369a00a06c

See more details on using hashes here.

File details

Details for the file pylx16a-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pylx16a-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pylx16a-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05fc9bac3bd3bb5feaaf236302ad9074b362794239cb10403f3c85cfc489f71c
MD5 47f372ab49ebcfe664c67e9942f0526a
BLAKE2b-256 598c83e0f195b6ad19f42f75df3a5229532aed495ed0b776d4e41a8d538dabbb

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