type
status
date
slug
summary
tags
category
icon
password
SG90 - Tower-Pro
Datasheet PDF
Product Usage Guide 使用教程
How to use a Micro Servo Motor
The micro servo motor (0.12s / 1.2kg-cm - 9g SG90) is a small motor which turns up to 180 degrees or ranges between 90, 180, or 270 degrees depending on the make or type, but never 360.

How it works
The Servo motor is an electromechanical device that rotates and changes movement based on the supplied current and voltage. The Servo works as a closed loop system that provides torque and velocity as commanded from its controller. This allows the servo to receive feedback to know when to close the loop. When connected to a programmable circuit board, this device uses the Pulse Width Modulation pins.
-37ef96064769f61ec471c7ac64caa5ca.jpg?t=1baeed39-9579-474b-8625-21486d3d55f1)
-70eec649c3d9cab9fd7dfb773c06963d.jpg?t=b661fd4d-ae1d-4e5c-9d56-c66366a772e9)
-afa3847f686ba12980280d18d10c93e3.jpg?t=c66fcb92-a256-4156-807e-becaaad7eb54)
Wiring
- Red Wire: connected to 5V
- Black Wire: connected to ground
- Brown Wire: connect to a PWM pin (#~)
-ec0aede5c0aae0994eb652cf943e55dc.jpg?t=c9667c28-38dd-41fe-8be2-27e04a52b016)
Parts
Wiring Guide
- Connect the voltage and ground wires to the appropriate connection to the Servo
- Connect the signal wire of the Servo to a PWM pin in the digital input pin section of the Arduino board
- Connect the terminal pins of the potentiometer to voltage and ground
- Connect the wiper pin of the potentiometer to an analog pin
- Follow the code provided and observe how the servo rotates as you change the values of the potentiometer
Programming
The following code demonstrates how you can move the servo motor by mapping the potentiometer. If you want to skip the steps, you can jump to the Full Code.
Step 1: Create variables for the sensors pin and a variable to store the data that is collected
Step 2: Set up serial communication, set the sensor pin as an INPUT.
Step 3: Read the data from the sensor, and convert the data into a volts measurement
Step 4: Now convert the volts measurement into distance, a measurement we understand. This calculation is found in the datasheet gragh of the component and can be found here!
Step 5: Finally use the distance we calculated and display ONLY when the distance is less than or equal to its max limit.
Full Code
Output
Serial Monitor will display distance that is measure from the proximity sensor, only if the distance measure is less than or equal to the max limit which is 30cm for this exact component.
📎 参考文章
- 作者:YOUNGQI
- 链接:https://blog.creatforlyq.eu.org/article/SG_90
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。