Snag the STLs and OpenSCAD files from:
You don’t need any special code if you’re just using a stock MG995 servo.
But if you’re hacking your servo for continuous rotation and adding a potentiometer and a limit switch, check the code for some ideas:
Interrupt.h is basically a C++ wrapper for the C interrupts generated by the limit switch and potentiometer.
LinearActuator.h is sort of a driver for the linear actuator. It extends Interrupt.h and figures out what interrupt was called using the handle() method.