

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).
Servo motor arduino precision 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. Give this project a try for yourself! Get the BOM.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. Int potentio = A0 // initialize the A0analog pin for potentiometerĪngle = analogRead(potentio) // reading the potentiometer value between Īngle = map(angle, 0, 1023, 0, 179) // scaling the potentiometer value to angle value for servo between 0 and 180) Once the program is started, rotating the potentiometer should cause the shaft of the servo motor to rotate. Potentiometer pin 2 – Analog In (A0) pin Arduino.Potentiometer pin 3 - Ground pin Arduino.Hardware RequiredĬonnect the circuit as show in the figure below: The Arduino will read the voltage on the middle pin of the potentiometer and adjust the position of the servo motor shaft. This experiment is essentially the same as Experiment 1, except that we have added a potentiometer for position control. Servo_test.write(angle) //command to rotate the servo to the specified angle Servo_test.attach(9) // attach the signal pin of servo to pin9 of arduinoįor(angle = 0 angle =1 angle-=5) // command to move from 180 degrees to 0 degrees Servo servo_test //initialize a servo object for the connected servo When the motor has rotated 180 degrees, it will begin to rotate in the other direction until it returns to the home position.


When the program starts running, the servo motor will rotate slowly from 0 degrees to 180 degrees, one degree at a time. Connect to the motor to the Arduino as shown in the table below:Ĭaution: Do not try to rotate the servo motor by hand, as you may damage the motor. The best thing about a servo motor is that it can be connected directly to an Arduino. The PWM input will be connected to one of the Arduino's digital output pins. In this experiment, we will connect the power and ground pins directly to the Arduino 5V and GND pins. Most servo motors have the following three connections: Servo motors are small in size, and because they have built-in circuitry to control their movement, they can be connected directly to an Arduino. As a result, servo motors are used to control the position of objects, rotate objects, move legs, arms or hands of robots, move sensors etc. You can connect small servo motors directly to an Arduino to control the shaft position very precisely.īecause servo motors use feedback to determine the position of the shaft, you can control that position very precisely.
