发布于: 2024-2-18最后更新: 2024-2-21字数 00 分钟

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.
notion image

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.
notion image
notion image
notion image

Wiring

  • Red Wire: connected to 5V
  • Black Wire: connected to ground
  • Brown Wire: connect to a PWM pin (#~)
notion image

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.

📎 参考文章

 
 

  • Giscus
  • Cusdis
  • Utterance
(6)点亮一颗LED灯
(6)点亮一颗LED灯
Keil无法识别WCHLink解决方法
Keil无法识别WCHLink解决方法
公告
type
status
date
slug
summary
tags
category
icon
password
🎉YOUNGQI的个人博客已经上线🎉
👏感谢您的拜访与交流学习👏
本站不收集任何信息,无安全隐患,请大家放心访问。