

Now we need to define a name for the servo “Servo sg90sevo”, here ‘sg90servo’ is the name chosen, so while writing for potion we are going to use this name, this feature comes in handy when we have many servos to control, we can control as many as eight servo by this. Sg90.attach(servo_signal_pin_attached_to) įirst we need to set frequency of PWM signal and for that we should call “#include ” header file, on including this header file in the program, the frequency gets set automatically and we get to use some special conditions, which enables the user to enter needed position of servo directly without any fuzz.The things which we need to do for getting accurate position of servo are: In ARDUINO we simply have to state the position of servo that needed and the PWM is automatically be adjusted by UNO. In ARDUINO we have predefined libraries, which will set the frequencies and duty ratios accordingly once the header file is called or included. In normal cases we need to go to the registers of controller for adjusting the frequency and for getting required duty ratio for accurate position control of servo, in ARDUINO we don’t have to do those things. Hardware: ARDUINO UNO, power supply (5v), 100uF capacitor, buttons (two pieces), 1KΩ resistor (two pieces), Servo motor (which needed to be tested).Īrduino Servo Motor Circuit Diagram and Explanation 1ms of ON time and 17ms of OFF time in a 18ms signal.įor the shaft to be moved to 12o clock the ON time of signal must be 1.5ms and OFF time should be 16.5ms. This ratio is decoded by control system in servo and it adjusts the position based on it. This PWM in here is generated by using ARDUINO UNO. Based on this DUTY RATION the control electronics adjust the shaft.Īs shown in figure below, for the shaft to be moved to 9o clock the TURN ON RATION must be 1/18.ie. The important thing here is the DUTY RATIO of the PWM signal. The frequency of PWM (Pulse Width Modulated) signal can vary based on type of servo motor. This data regarding position of shaft is sent through the SIGNAL pin. The position data to the control should be sent in the form of PWM signal through the Signal pin of servo motor. Simply speaking the control electronics adjust shaft position by controlling DC motor. The RED wire is connected to power, Black wire is connected to ground and YELLOW wire is connected to signal.Ī servo motor is a combination of DC motor, position control system, gears. The position of the shaft of the DC motor is adjusted by the control electronics in the servo, based on the duty ratio of the PWM signal the SIGNAL pin. A servo motor will have mainly there wires, one is for positive voltage another is for ground and last one is for position setting. Servo motors are available at different shapes and sizes. These motors are used in robotic arm machines, flight controls and control systems. These are proposed for low speed, medium torque and accurate position application. These are not proposed for high speed applications. Servo Motors are used where there is a need for accurate shaft movement or position. In this tutorial we are going to control a servo motor by ARDUINO UNO.
