Giter Site home page Giter Site logo

lx16a-servo's Introduction

LX-16A Servo Library

Simple ESP32-Arduino library to operate LX-16A serial servos.

This library sends simple commands to LewanSoul LX-16A serial bus servos. It is designed for the ESP32 Arduino framework and uses a single pin to interface to the servos as opposed to the more common 3-pin configuration (TX, RX, direction).

The library's LX16AServo class provides two main methods to write a command and to read settings. It's very simple!

Quick start

Allocate a bus object to represent the serial line, and a servo object for the first servo:

LX16ABus servoBus;
LX16AServo servo(servoBus, 1);

Initialize the bus to use Serial1 on pin 33:

servoBus.begin(Serial1, 33);

Step servo through its 240 degrees range, 10% at a time:

int n = 0;
loop() {
    uint16_t angle = (n%11) * 100;

    uint8_t params[] = { (uint8_t)angle, (uint8_t)(angle>>8), 500&0xff, 500>>8 };
    bool ok = servo.write(1, params, sizeof(params));
    printf("Move to %d -> %s\n", angle, ok?"OK":"ERR");

    delay(10);

    ok = servo.read(2, params, 4);
    printf("Position at %d -> %s\n", params[0]|(params[1]<<8), ok?"OK":"ERR");

    n++;
    delay(2000);
}

High-level methods

The library implements a number of high-level functions which correspond to the lx16-a commands. For example:

// angle_adjust sets the position angle offset in centi-degrees (-3000..3000)
bool angle_adjust(int16_t angle);

// temp_read returns the servo temperature in centigrade
bool temp(uint8_t &temp);

Not all commands have been implemented, but it's easy to add any that are needed and missing. See src/LC16AServo.h.

lx16a-servo's People

Contributors

madhephaestus avatar tve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lx16a-servo's Issues

Docs: hardware setup

Hi,

What hardware setup are you using to connect the ESP32 to the servos? Is it as simple as wiring the ESP32 serial pin to the data pin on the first LX16A?

Looks like a nice library you've made. Thanks!

can you publish this library into the arduino library manager?

as per these instructions:
https://github.com/arduino/Arduino/wiki/Library-Manager-FAQ

You need a

library.properties

and to add the library to the Arduino issues to be added to the manager. Here is an example of someone else adding a new library: arduino/Arduino#9648

You will then just need to tag the repo with a version number matching the library.properties version number.

If you have no intent to publish through the manager, would you object to me forking and doing that?

Compatibility with LX-224, LDX-218

Hey there,
Do you know if this library will also work with LX-224 and/or LDX-218 servos?

Thank you for creating this library. :)

All the best,
Dax.

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.