Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save specialcircumstances/006629561b0941894934c1702c139efb to your computer and use it in GitHub Desktop.
Save specialcircumstances/006629561b0941894934c1702c139efb to your computer and use it in GitHub Desktop.
Driving LewanSoul LX-16A Serial Servo Directly from Particle Photon
// GIST to outline driving this very cost effective serial servos directly from Particle Photons
// Turns out the servo uses half duplex, and requires an Open Drain
// Turn off echo, or we can't read.
// According to my nScope although the docs say pull-up to 5V I can see it's a 3.3V that's 5V tolerant
// ... just like the photon...
// So, anyway, 3.3V works just fine. Link to the TX pin (that's Serial1). RX pin is unused.
// I used an external 10K pull-up to the 3.3V pin on the photon. You might be able to do this internally too?
//
// Power the servo separately to > 6V, so be a little careful with your wiring (cos the servo power will fry your serial pin)
// I power from two 18650s, so between 7 and 8 V with a step-down to 5V for the Photon
// I use the LewanSoul libraries which you can get from their site http://bit.ly/2Arw3QM
// There is a library, but also some simple Arduino sketches, which are probably easier to hack
// You need to replace the serial device type (e.g. USARTSerial not HardwareSerial) to compile
// e.g. int LobotSerialServoReadError(USARTSerial &SerialX, uint8_t id)
// Init the serial as so.
void setup() {
Serial1.halfduplex(true);
Serial1.begin(115200, SERIAL_HALF_DUPLEX_OPEN_DRAIN | SERIAL_HALF_DUPLEX_NO_ECHO);
}
// The rest should be self explanatory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment