

The MG90S technically has a working voltage input range of 4.8V - 6.0V, so any 5.0V Arduino should work, assuming it has pulse-width modulation (PWM) capabilities. First, the servo needs to be wired to an Arduino board. The Arduino library is a great place to start, as it really only requires a few lines of code. Right out of the box, MG90S servos work with the prescribed Arduino ‘Servo’ code, which rotates the servo back and forth based on its built-in servo library. Both the MG90S and the SG90 are wired the same and use similar code. The MG90S is also slightly faster than the SG90, which is a further justification for why it is used here. The MG90S is another small servo motor that is similar to the SG90, but weighs slightly more (14g) and has metal gears instead of plastic. The goal of this project is to introduce users into the workings of a servo motor, how PWM (pulse-width modulation) controls a servo motor, and how Arduino can interface with servo motors to produce desired movements to great precision. The basics and composition of an SG90 will be explored, and the application of several servo codes and applications will be given for another type of servo motor, the MG90S. In this tutorial, an Arduino board will be used to power and control a small servo motor.

Lastly, servo motors use a circuit to control and send feedback information to a given controller, which in our case is an Arduino board (read more about servo motors here).
#Wire servo motor arduino series
Often, servo motors contain a series of gears that either speed up or slow down and smooth the movement of the DC motor. The low-cost servos that are found in maker projects use potentiometers to register voltages as positions on the rotating plane of the servo. Servo motors are often comprised of DC motors that use feedback mechanisms to move with great precision from one position to another. Now, you should see the servo rotate from 0 to 180 degrees, and then do it in the opposite direction.Servo motors can be found in robotic arms, cameras, lathes, CNC machines, printing presses, and other engineering applications where precision and repeated movement are required. PinMode(servopin,OUTPUT) //Set the servo interface as the output interfaceģ. Compile the program and upload to Arduino UNO board Int pulsewidth=(angle*11)+500 //The angle is converted to a pulse width value of 500-2480ĭigitalWrite(servopin,HIGH) //The servo interface level to the highestĭelayMicroseconds(pulsewidth) //The number of microseconds of the delay pulse width valueĭigitalWrite(servopin,LOW) //The servo interface level to lowĭelayMicroseconds(20000-pulsewidth) //20000 can be replaced: "frequency = 1 / (20000/1000000)" Void servopulse(int angle)//Define an impulse function Int angle =0 //Angle of rotation of the servo Int servopin = 9 //Define servo interface digital interface 7 Be sure to connect the grounds of the Arduino and external power supply together.Ģ. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. Usually the signal pin is yellow, orange or white, and should be connected to a digital pin on the Arduino board. Note that the servo motor draws a considerable amount of power, if you need to drive more than one or two servos, you’ll probably need to power them with an extra supply (i.e. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The servo motor has three wires: power, ground, and signal. So we provide the following method: adjust corresponding frequency according to different servos. Different types of steering gear has different operating frequency. Through our study different steering gears were found. We found that if the Arduino provided by the library was used, some of the servo can not accurately rotate the angle we need. In this section, we will use the new method to control the servo.
