

In the loop function, the motor is rotated to four different positions by the write method. In the setup function, pin number 3 is made known to the servo object. I made use of the servo library to control the MG 996R motor. +5V (Powering the motor directly from the Arduino, might damage the Arduino) Next, Arduino’s pin #3 is wired to the orange input of the servo motor. Luckily, it is easily possible to connect two male jumper wires to a single terminal block of the adapter. In order to guarantee the same signal level, the terminal adapter’s “-” signal is wired to one of the Arduino’s GND pins. Accordingly, the “+” signal is wired to the servo’s red input. The “-” signal from the USB terminal adapter is wired to the brown input of the servo motor. For the wiring, I made use of a USB terminal adapter. In particular, I took a 5V USB power supply (power bank) to power the motor. In order to overcome this problem, I wired the motor to an external power supply. As a consequence, the Arduino might get damaged. The motor will likely draw to much current from the Arduino. Unfortunately, the motor can’t be directly powered from the Arduino.

The motor has three wires: Brown (GND), Red (+5V) and Orange (PWM signal). If the motor has completed the last position, the sequence starts again. The motor rotates to four different positions with a delay of one second in between. The example application is kept very simple. Caution: There are different manufacturers, values might vary. For example, you can see the MG 996R very frequently in 3D-printed robotic arm applications. In contrast to the likewise popular SG90 servo, the MG 996R is able to rotate much higher weights. The MG 996R is a popular servo motor within the Arduino Community. Moreover, this tutorials includes a simple code example that let’s the motor rotate to various rotary positions.
KOOKYE SERVO MOTOR ARDUINO CODE HOW TO
This tutorial shows how to wire the MG 996R servo to an Arduino. The MG 996R is one of the most popular servo motors within the maker community. A servo motor allows to precisely control a shaft to a specific rotary position.
