This is a library for servomotors: model names LX-16A and LX-224. I developed it with Adafruit Metro board and tested on ESP32 boards. The library is fully open-source and published here:
How does it work? It needs a bus linker (USB debug board) for these motors, and utilizes UART (RX and TX pins). Can it be used without the bus linker? Yes, but only to send commands, not to receive them.
The library provides a convenient class to control these servos.
For instance, to rotate to the given position/angle (for LX-16A from 0 to 240), call:void move(float angle, uint16_t time = 0, bool wait = false);
To read a physical angle at which the servo is currently positioned:float getPhysicalAngle();
The comprehensive set of methods allow to read temperature and voltage, set and get the mode of operation (motor or servo), set or get if torque is enabled, if an LED is enabled, change servo id, prepare a movement and execute it later.
Below is an example of the code to control the servo in a simple manner.
#include <Arduino.h>
#include "LX16A-bus.h"
LX16A motor1(1, Serial);
LX16A motor2(2, Serial);
void setup() {
Serial.begin(115200);
motor1.initialize();
motor1.enableTorque();
motor2.initialize();
motor2.enableTorque();
motor1.setServoMode();
motor2.setServoMode();
}
void loop() {
float angle = motor1.getPhysicalAngle();
delay(50);
Serial.print("angle: ");
Serial.println(angle);
motor1.move(240);
delay(1000);
motor2.move(240);
delay(2000);
angle = motor1.getPhysicalAngle();
delay(50);
Serial.print("angle: ");
Serial.println(angle);
motor1.move(0);
delay(1000);
motor2.move(0);
delay(2000);
}
This page (LX-16A Library for Arduino) was last updated on August 14, 2026.