https://github.com/roboticsbrno/esp32-lx16a
https://github.com/roboticsbrno/esp32-lx16a
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/roboticsbrno/esp32-lx16a
- Owner: RoboticsBrno
- Created: 2023-04-13T07:18:25.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-01T20:29:46.000Z (about 3 years ago)
- Last Synced: 2025-04-03T09:46:28.203Z (about 1 year ago)
- Language: C++
- Size: 75.2 KB
- Stars: 2
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Esp32-lx16a
Library for controlling lx16a and similar servos that actually works on ESP32.
## Example
Add current version to your platformio.ini:
```ini
...
lib_deps = https://github.com/RoboticsBrno/Esp32-lx16a/archive/refs/tags/v1.2.1.zip # or newer version...
...
```
```cpp
#include
#include "SmartServoBus.hpp"
using namespace lx16a;
static SmartServoBus servoBus;
void setup() {
// Servos on the bus must have sequential IDs, starting from 0 (not 1)!
// The '1' below is count of servos on the bus, not servo ID.
servoBus.begin(1, UART_NUM_2, GPIO_NUM_14);
/*
// Set servo Id (must be only one servo connected to the bus)
servoBus.setId(0);
while (true) {
printf("GetId: %d\n", servoBus.getId());
delay(1000);
}
*/
printf("Current pos: %f\n", servoBus.pos(0).deg());
servoBus.set(0, 180_deg);
}
void loop() {
}
```