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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pylx16a-1.0.2.tar.gz.
File metadata
- Download URL: pylx16a-1.0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abbb5dc992ae1edd58b2786dac79801eeb173f03bd605e1527f17d6d71b94ca1
|
|
| MD5 |
702105ae67cdd5aface444ecfb94d580
|
|
| BLAKE2b-256 |
bbb55d7dd687756fef27732d37d95a44d954807cb034135570cb0cc1dcb44a10
|
File details
Details for the file pylx16a-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pylx16a-1.0.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e4d6cbbf7521f8eef1bb5d94cc254359ca0a28802e1acf02299f65ada53649a
|
|
| MD5 |
a86a89b3ca1a82b59c1868257d65926d
|
|
| BLAKE2b-256 |
a929dc44d2ae25f27770590566be9cbc372806cdd6a47e0b8ae75b64e8b07381
|