Changing a servo library to work with a new microcontroller


I recently purchased two Adafruit Feather M0's with RFM95 radio. The goal is to use one at a base station that controls a pneumatic valve, with the other remote operating a suite of servos.

I am using the Pololu XYZ robot servo for their strength and embedded capabilities, but the library used, which can be found here, is based on SoftwareSerial to control the servo via something like an Arduino Uno or Mega. The Feather, on the other hand, uses SERCOM to define serial communication pins, and I can't get them to work with these servos with the existing library.

Does anyone have any suggestions as to what the best approach is to either modify the header or my personal code?


Adafruits forum has a topic that might help:

Software serial isn't necessary due to hardware serial with feather.

Can you post your code and outputs and let us know how far you are getting, if anywhere with talking between the two

So here is the header code and definition of serial object

#include <XYZrobotServo.h>

// On boards with a hardware serial port available for use, use
// that port. For other boards, create a SoftwareSerial object
// using pin 10 to receive (RX) and pin 11 to transmit (TX).
#include <SoftwareSerial.h>
SoftwareSerial servoSerial(10, 11);

It seems like the first line defining the hardware serial port fails, and instead the code is defining the software serial object. For the Feather, do I need to change the definition of servoSerial from SERIAL_PORT_HARDWARE_OPEN to something else?

Sorry, forgot to mention what I am trying to do initially. Right now, I am just trying to get the Feather to detect and turn the servos via serial communication. After that, I will be attempting to get two feathers to talk to one another, and have the base unit command the remote unit to move the servos. The example code from pololu to detect the servos worked with little modification on the Uno, but I have been unable to get it to work on the Feather

Im not 100% on Hardware serials so you might have to wait for someone with more knowledge in that area.

However; I assume your board does have Hardware serial? Or you are prepping incase it does?

SERIAL_PORT_HARDWARE_OPEN is usually defined in <pins_arduino.h> when I have seen it. Do you have a library that is using it currently and it is included?

Also have you tried swapping from SERIAL_PORT_HARDWARE_OPEN to just the Serial1 (or whatever port it is) just to test which part isnt working?

You know, that was exactly what I had to do (change it to Serial1) and now it works perfectly. Thanks for the help!