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.1.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.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylx16a-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 44ef4ee00646df24fa105f44507c24be6deb2452586e757bb813b9cc29b095dc
MD5 7c3cb6229a7a2c670ed1bfdc0e3a41cd
BLAKE2b-256 6ee4cb9be23ab069bd63eadd25b5098c565c9967f45241f553aa7b0204c9f93c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylx16a-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19a5f5917c9538df2ec6bf0f4af667dcc59a6d903d9c68725d7c0354d6f3ee57
MD5 bc691e1c50258e1462b44c2c0f48943f
BLAKE2b-256 71f12e36dab6fdc08da328908b2097b6531580aabf137a10734d4b325464e193

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