GithubHelp home page GithubHelp logo

alecxcode / pylx-16a Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ethanlipson/pylx-16a

0.0 0.0 0.0 135 KB

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

Home Page: https://www.ethanlipson.com/portfolio

License: MIT License

Python 100.00%

pylx-16a's Introduction

PyLX-16A

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

Install and Setup

This library requires a Python version >= 3.10. You can install using pip:

python3.10 -m pip install pylx16a

On Linux, you can 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

/dev/ttyUSB0 is most likely the connected port on Linux. On Windows, try the COM ports instead, e.g. LX16A.initialize("COM3").

from math import sin, cos, pi
from pylx16a.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

pylx-16a's People

Contributors

ethanlipson avatar bsilva-bentlabs avatar alecxcode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.