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 Raspberry Pi™ 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. Typically, a servo accepts pulse width durations in the range of 1 to 2 milliseconds where:
1 millisecond pulse-width maps to an angle of 0 degrees
2 millisecond pulse-width maps to an angle of 180 degrees
Exceeding the specified minimum or maximum pulse-width of a servo can cause damage to servo motor. Always check the data sheet specifications for your servo motor module.