Stufin
Home Quick Cart Profile

MG958 Servo Motor

Buy Now on Stufin

Pin Configuration

  • MG958 Servo Motor Pinout Documentation
  • The MG958 servo motor is a popular and widely used component in various IoT and robotics applications. This documentation aims to provide a comprehensive explanation of the pins and their connections to facilitate easy integration into projects.
  • Pinout Structure:
  • The MG958 servo motor has a 3-pin connector, and the pinout structure is as follows:
  • Pin 1: VCC (Red Wire)
  • Function: Power Supply (Positive Voltage)
  • Description: This pin connects to the positive voltage supply of the servo motor. Typically, this is connected to a power source with a voltage range of 4.8V to 6V.
  • Connection: Connect to a power source (e.g., battery or power adapter) with a voltage range of 4.8V to 6V.
  • Pin 2: GND (Brown Wire)
  • Function: Ground (Negative Voltage)
  • Description: This pin connects to the negative voltage supply or ground of the servo motor.
  • Connection: Connect to the ground or negative terminal of the power source.
  • Pin 3: SIG (Yellow or Orange Wire)
  • Function: Signal (Control Signal)
  • Description: This pin receives the control signal from the microcontroller or other control devices to operate the servo motor.
  • Connection: Connect to a digital output pin of a microcontroller (e.g., Arduino, Raspberry Pi) or other control devices.
  • Connection Guidelines:
  • Ensure proper polarity when connecting the power supply to the servo motor. Reversing the polarity may damage the motor.
  • Use a suitable gauge wire for connections to prevent voltage drops and ensure reliable operation.
  • Keep the signal wire (Pin 3) away from power supply and ground wires to minimize electromagnetic interference (EMI).
  • Additional Notes:
  • The MG958 servo motor typically draws a current of around 100-150mA when stationary and up to 500mA when rotating.
  • The motor's rotation speed and direction are controlled by the control signal received on Pin 3. The signal frequency and pulse width determine the motor's movement.
  • It is recommended to use a servo motor driver or controller to operate the MG958 servo motor, especially when using a microcontroller with limited output current capacity.
  • By following these guidelines and pinout explanations, you can successfully connect and operate the MG958 servo motor in your IoT or robotics projects.

Code Examples

MG958 Servo Motor Documentation
Overview
The MG958 Servo Motor is a high-torque, high-precision servo motor designed for use in various robotics, automation, and IoT applications. It features a built-in position sensor and a built-in drive circuit, making it easy to control and integrate into digital systems.
Technical Specifications
Operating Voltage: 4.8V to 7.2V
 Stall Torque: 19 kg.cm
 Speed: 0.15 sec/60
 Position Resolution: 0.5
 Operating Temperature: -20C to 60C
Pinout
VCC: Power supply pin (4.8V to 7.2V)
 GND: Ground pin
 Signal: Control signal pin (PWM)
Code Examples
### Example 1: Basic Servo Control using Arduino
This example demonstrates how to control the MG958 Servo Motor using an Arduino board.
```cpp
#include <Servo.h>
Servo servo;  // create a servo object
void setup() {
  servo.attach(9);  // attach the servo to digital pin 9
}
void loop() {
  servo.write(0);  // set the servo to 0 degrees
  delay(1000);
servo.write(90);  // set the servo to 90 degrees
  delay(1000);
servo.write(180);  // set the servo to 180 degrees
  delay(1000);
}
```
### Example 2: Servo Control using Raspberry Pi and Python
This example demonstrates how to control the MG958 Servo Motor using a Raspberry Pi and Python.
```python
import RPi.GPIO as GPIO
import time
# set up GPIO mode
GPIO.setmode(GPIO.BCM)
# set up the servo pin
servo_pin = 17
GPIO.setup(servo_pin, GPIO.OUT)
# set up the servo object
pwm = GPIO.PWM(servo_pin, 50)  # 50 Hz frequency
# start the servo
pwm.start(0)
try:
    while True:
        pwm.ChangeDutyCycle(2.5)  # set the servo to 0 degrees
        time.sleep(1)
pwm.ChangeDutyCycle(7.5)  # set the servo to 90 degrees
        time.sleep(1)
pwm.ChangeDutyCycle(12.5)  # set the servo to 180 degrees
        time.sleep(1)
except KeyboardInterrupt:
    pwm.stop()
    GPIO.cleanup()
```
Note: In the above examples, the servo motor is controlled using PWM (Pulse Width Modulation) signals. The duty cycle of the PWM signal determines the position of the servo motor. The duty cycle values may vary depending on the specific servo motor and application.