Servo motors have integrated circuitry inside the motor unit. The shaft is typically fitted with a gear and can be positioned as needed. You can use MATLAB® Support Package for Arduino® Hardware to control movement of the shaft.
Servo motors can turn in either direction. You can control the angle at which the motor can turn based on the maximum and minimum pulse-width duration.
To create a custom servo code, see Create Custom Arduino Add-On Library