Chuyển tới nội dung
Home » Drive Servo Motor Arduino | Arduino Servo Motor Control

Drive Servo Motor Arduino | Arduino Servo Motor Control

How to Control a Servo With an Arduino

Arduino and PCA9685 PWM/ Servo Driver

There’s also another way of controlling servos with Arduino, and that’s using the PCA9685 servo driver. This is a 16-Channel 12-bit PWM and servo driver which communicates with Arduino using the I2C bus. It has a built in clock so it can drive 16 servos free running, or independently of Arduino.

What’s even cooler we can daisy-chain up to 62 of these drivers on a single I2C bus. So theoretically we can control up to 992 servos using only the two I2C pins from the Arduino board. The 6 address select pins are used for setting different I2C addressed for each additional driver. We just need to connect the solder pads according to this table.

Here’s the circuit schematic and we can once again notice that we need a separate power supply for the servos.

You can get the components needed for this example from the links below:

  • MG996R Servo Motor …………………………. Amazon / Banggood / AliExpress
  • PCA9685 PWM Servo Driver ………………. Amazon / Banggood / AliExpress
  • Arduino Board ……………………………………. Amazon / Banggood / AliExpress
  • 5V 6A DC Power Supply …………………..….. Amazon / Banggood / AliExpress

Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

Now let’s take a look at the Arduino code. For controlling this servo driver we will use the PCA9685 library which can be downloaded from GitHub.

Arduino and PCA9685 Code


/* Servo Motor Control using Arduino and PCA9685 Driver by Dejan, https://howtomechatronics.com Library: https://github.com/NachtRaveVL/PCA9685-Arduino */ PCA9685 driver; // PCA9685 outputs = 12-bit = 4096 steps // 2.5% of 20ms = 0.5ms ; 12.5% of 20ms = 2.5ms // 2.5% of 4096 = 102 steps; 12.5% of 4096 = 512 steps PCA9685_ServoEvaluator pwmServo(102, 470); // (-90deg, +90deg) // Second Servo // PCA9685_ServoEvaluator pwmServo2(102, 310, 505); // (0deg, 90deg, 180deg) void setup() { Wire.begin(); // Wire must be started first Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz driver.resetDevices(); // Software resets all PCA9685 devices on Wire line driver.init(B000000); // Address pins A5-A0 set to B000000 driver.setPWMFrequency(50); // Set frequency to 50Hz } void loop() { driver.setChannelPWM(0, pwmServo.pwmForAngle(-90)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(0)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(90)); delay(1000); }

Code language: Arduino (arduino)

So first we need to include the libraries and define the PCA9685 object. Then using the Servo_Evaluator instance define the pulses duration or the PWM output of the driver. Note that the outputs are 12-bit, or that’s a resolution of 4096 steps. So the minimum pulse duration of 0.5ms or 0 degrees position would correspond to 102 steps, and the maximum pulse duration of 2.5ms or 180 degrees position to 512 steps. But as explained earlier these values should be adjusted according your servo motor. I had value from 102 to 470 which corresponded to 0 to 180 degrees position.

In the setup section we need to define the I2C clock rate, set the driver address and set the frequency to 50Hz.

In the loop section, using the setChannelPWM() and pwmForAngle() functions we simply set the servo to the desired angle.

I connected a second servo to the driver, and as I expected, it wasn’t positioning the same as the first one, and that’s because the servos that I’m using are cheap copies and they are not so reliable. However, this isn’t a big problem because using the Servo_Evaluator instance we can set different output settings for each servo. We can also adjust the 90 degrees position in case it’s not precisely in the middle. In that way all servos will work the same and position at the exact angle.

Controlling a lot of servos with Arduino and the PCA9685 drivers

We will take a look at one more example and that’s controlling a lot of servos with multiple chained PCA9685 drivers.

For that purpose we need to connect the drivers to each other and connect the appropriate address select solder pads. Here’s the circuit schematic:

Let’s take a look at the Arduino code now.


/* Servo Motor Control using Arduino and PCA9685 Driver by Dejan, https://howtomechatronics.com Library: https://github.com/NachtRaveVL/PCA9685-Arduino */ PCA9685 driver; // PCA9685 outputs = 12-bit = 4096 steps // 2.5% of 20ms = 0.5ms ; 12.5% of 20ms = 2.5ms // 2.5% of 4096 = 102 steps; 12.5% of 4096 = 512 steps PCA9685_ServoEvaluator pwmServo(102, 470); // (-90deg, +90deg) // Second Servo PCA9685_ServoEvaluator pwmServo2(102, 310, 505); // (0deg, 90deg, 180deg) void setup() { Wire.begin(); // Wire must be started first Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz driver.resetDevices(); // Software resets all PCA9685 devices on Wire line driver.init(B000000); // Address pins A5-A0 set to B000000 driver.setPWMFrequency(50); // Set frequency to 50Hz } void loop() { driver.setChannelPWM(0, pwmServo.pwmForAngle(-90)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(0)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(90)); delay(1000); }

Code language: Arduino (arduino)

So we should create separate PCA9685 object for each driver, define the addresses for each driver as well as set the frequency to 50Hz. Now simply using the setChannelPWM() and pwmForAngle() functions we can set any servo at any driver to position any angle we want.

Popular RC / Hobby Servos for Arduino Projects

There are many different models and manufacturers of RC or hobby. The main consideration when choosing a servo motor is its torque, operating voltage, current draw and size.

Here are the two most popular servo models among makers, the SG90 Micro Servo and the MG996R.

SG90 Micro Servo technical specifications:

Stall Torque 1.2kg·cm @4.8V, 1.6kg·cm @6V,
Operating Voltage 3.5 – 6V
No Load Current 100mA
Stall Current 650mA
Max Speed 60 degrees in 0.12s
Weight 9g

MG996R Servo technical specifications:

Stall Torque 11kg.cm @4.8v, 13kg.cm @6V
Operating Voltage 4.8 – 7.2V
No Load Current 220mA @4.8V, 250mA @6V
Stall Current 650mA
Max Speed 60 degrees in 0.20s
Weight 55g
How to Control a Servo With an Arduino
How to Control a Servo With an Arduino

Troubleshooting

Sometimes, your servo may misbehave, especially if you decide to operate it directly from the Arduino. The reason for this is that the servo consumes a significant amount of power, particularly during startup, which can cause the Arduino board to reset.

To solve this problem, place a relatively large electrolytic decoupling capacitor (470µF – 1000µF) across the input power. Make sure the capacitor’s longer lead is connected to 5V and the negative lead is connected to GND.

The capacitor stores electric charge, so when the motor starts, it draws power from both the Arduino supply and the capacitor, ensuring a smooth flow of current.

Step 3: How It Works

Servos are clever devices. Using just one input pin, they receive the position from the Arduino and they go there. Internally, they have a motor driver and a feedback circuit that makes sure that the servo arm reaches the desired position. But what kind of signal do they receive on the input pin?

It is a square wave similar to PWM. Each cycle in the signal lasts for 20 milliseconds and for most of the time, the value is LOW. At the beginning of each cycle, the signal is HIGH for a time between 1 and 2 milliseconds. At 1 millisecond it represents 0 degrees and at 2 milliseconds it represents 180 degrees. In between, it represents the value from 0–180. This is a very good and reliable method. The graphic makes it a little easier to understand.

Remember that using the Servo library automatically disables PWM functionality on PWM pins 9 and 10 on the Arduino UNO and similar boards.

Code breakdown

The code simply declares the servo object and then initializes the servo by using the servo.attach() function. We shouldn’t forget to include the servo library. In the loop(), we set the servo to 0 degrees, wait, then set it to 90, and later to 180 degrees.

16 channel servo controller with Arduino | PCA9685 16 channel PWM servo motor driver tutorial
16 channel servo controller with Arduino | PCA9685 16 channel PWM servo motor driver tutorial

How Servo Motors Work?

There are four main components inside of a hobby servo, a DC motor, a gearbox, a potentiometer and a control circuit. The DC motor is high speed and low torque but the gearbox reduces the speed to around 60 RPM and at the same time increases the torque.

The potentiometer is attached on the final gear or the output shaft, so as the motor rotates the potentiometer rotates as well, thus producing a voltage that is related to the absolute angle of the output shaft. In the control circuit, this potentiometer voltage is compared to the voltage coming from the signal line. If needed, the controller activates an integrated H-Bridge which enables the motor to rotate in either direction until the two signals reach a difference of zero.

A servo motor is controlled by sending a series of pulses through the signal line. The frequency of the control signal should be 50Hz or a pulse should occur every 20ms. The width of pulse determines angular position of the servo and these type of servos can usually rotate 180 degrees (they have a physical limits of travel).

Generally pulses with 1ms duration correspond to 0 degrees position, 1.5ms duration to 90 degrees and 2ms to 180 degrees. Though the minimum and maximum duration of the pulses can sometimes vary with different brands and they can be 0.5ms for 0 degrees and 2.5ms for 180 degrees position.

Read More: Stepper Motors and Arduino – The Ultimate Guide

Circuit

Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to positive pole (+) of your power source. The ground wire is typically black or brown and should be connected to the negative pole (-) of your power source.

The signal pin is typically yellow or orange and should be connected to PWM pin on the board. In these examples, it is pin number 9.

Knob Circuit

For the Knob example, wire the potentiometer so that its two outer pins are connected to power (+5V) and ground, and its middle pin is connected to

on the board. Then, connect the servo motor as shown in the circuit below.

A0

Sweep Circuit

For the Sweep example, connect the servo motor as shown in the circuit below.

AC servo controlled with Arduino
AC servo controlled with Arduino

Introduction: Arduino Servo Motors

Servo motors are great devices that can turn to a specified position.

Usually, they have a servo arm that can turn 180 degrees. Using the Arduino, we can tell a servo to go to a specified position and it will go there. As simple as that!

Servo motors were first used in the Remote Control (RC) world, usually to control the steering of RC cars or the flaps on a RC plane. With time, they found their uses in robotics, automation, and of course, the Arduino world.

Here we will see how to connect a servo motor and then how to turn it to different positions.

The first motor I ever connected to an Arduino, seven years ago, was a Servo motor. Nostalgic moment over, back to work!

We will need the following things:

  1. An Arduino board connected to a computer via USB
  2. A servo motor
  3. Jumper wires

There are few big names in the servo motor world. Hitec and Futaba are the leading RC servo manufacturers. Good places to buy them are Servocity, Sparkfun, and Hobbyking.

This instructable and many more can be found in my Arduino Development Cookbook available here. 😀

Wiring Servo Motor to Arduino UNO

Let’s hook the servo motor to the Arduino.

We will be using an SG90 Micro Servo Motor in our experiments. It operates on 4.8-6VDC (5V typical) and can rotate 180 degrees (90 in each direction).

It draws about 10mA when idle and 100mA to 250mA when moving, so we can power it with the Arduino’s 5-volt output.

If your servo consumes more than 250mA, consider using a separate power supply for it.

Connect the red wire to the Arduino’s 5V and the black/brown wire to ground. Finally, attach the Orange/Yellow wire to PWM enabled pin #9.

The following table lists the pin connections:

Servo Motor Arduino
5V 5V
GND GND
Control

The image below shows how to connect SG90 servo motor to the Arduino.

Arduino tutorial 7- How to control Servo motor with Arduino (code explained) | using servo library
Arduino tutorial 7- How to control Servo motor with Arduino (code explained) | using servo library

Examples

Knob

Controlling a servo position using a potentiometer (variable resistor).

1#include

23Servo myservo; // create servo object to control a servo45int potpin = 0; // analog pin used to connect the potentiometer6int val; // variable to read the value from the analog pin78void setup() {9 myservo.attach(9); // attaches the servo on pin 9 to the servo object10}1112void loop() {13 val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)14 val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)15 myservo.write(val); // sets the servo position according to the scaled value16 delay(15); // waits for the servo to get there17}

Sweep

Sweeps the shaft of a RC servo motor back and forth across 180 degrees.

1#include

23Servo myservo; // create servo object to control a servo4// twelve servo objects can be created on most boards56int pos = 0; // variable to store the servo position78void setup() {9 myservo.attach(9); // attaches the servo on pin 9 to the servo object10}1112void loop() {13 for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees14 // in steps of 1 degree15 myservo.write(pos); // tell servo to go to position in variable ‘pos’16 delay(15); // waits 15ms for the servo to reach the position17 }18 for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees19 myservo.write(pos); // tell servo to go to position in variable ‘pos’20 delay(15); // waits 15ms for the servo to reach the position21 }22}

Suggested changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.

License

The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.

In this tutorial we will learn how servo motors work and how to control servo motors with Arduino. Servo motors are very popular and widely used in many Arduino projects because they are easy to use and provide great position control.

Servos are great choice for robotics projects, automation, RC models and so on. I have already used them in many of my Arduino projects and you can check out some of them here:

  • DIY Arduino Robot Arm with Smartphone Control
  • Arduino Ant Hexapod Robot
  • DIY Arduino based RC Hovercraft
  • SCARA Robot | How To Build Your Own Arduino Based Robot
  • DIY Mars Perseverance Rover Replica – Arduino based Project

You can watch the following video or read the written tutorial below. It includes several examples how to use a servo motor with Arduino, wiring diagram and codes. In additional, it has a guide how to control multiple servo motors with Arduino using the PCA9685 PWM driver.

Conclusion

So, we have covered almost everything we need to know about using servo motors with Arduino. Of course, there are some many manufacturers and models of these type of hobby or RC servo motors, and each of them has its own unique features that might differ from what we explained above.

The possibilities for creating awesome robotics, automation and RC projects using motors are endless, however choosing the right model for your application is very important.

I hope you enjoyed this tutorial and learned something new. Feel free to ask any question in the comments section below, as well as make sure you can my Arduino Projects Collection.

PCA9685 16-Channel 12-Bit PWM Servo Motor Driver with Arduino.
PCA9685 16-Channel 12-Bit PWM Servo Motor Driver with Arduino.

Dimensions and 3D Model

I made 3D models of the two most popular servo motors, the SG90 Micro Servo and the MG996R servo motor. You can download load them from the links below.

SG90 Micro Servo

3D Model: Download from Thangs.

Dimensions:

MG996R Servo Motor

MG996R Servo Motor 3D Model: Download from Thangs.

Dimensions:

Controlling Multiple Servo Motors with Arduino

The Arduino servo library supports controlling of up to 12 servos at the same time with most the Arduino boards, and 48 servos using the Arduino Mega board. On top of that, controlling multiple servo motors with Arduino is as easy as controlling just a single one.

Here’s an example code for controlling multiple servos:


/* Controlling multiple servo motors with Arduino by Dejan, https://howtomechatronics.com */ Servo servo1; Servo servo2; Servo servo3; Servo servo4; Servo servo5; void setup() { servo1.attach(8); servo2.attach(9); servo3.attach(10); servo4.attach(11); servo5.attach(12); } void loop() { // move all servos to position 0 servo1.write(0); servo2.write(0); servo3.write(0); servo4.write(0); servo5.write(0); delay(2000); // move all servos to position 90 servo1.write(90); servo2.write(90); servo3.write(90); servo4.write(90); servo5.write(90); delay(2000); // move all servos to position 180 servo1.write(180); servo2.write(180); servo3.write(180); servo4.write(180); servo5.write(180); delay(2000); }

Code language: Arduino (arduino)

So, we just have to create objects from the Servo class for each servo motor, and define to which Arduino pin is connected. Of course, we can set any servo to move to any position, at any time.

As an example you can also check my Arduino Ant Hexapod Robot project where I used an Arduino MEGA board to control 22 servo motors.

Using Servo Motors with Arduino
Using Servo Motors with Arduino

Testing it out

After we have successfully uploaded the code to the board, the standard servo should now start moving from 0 – 180, and then start moving from 180 – 0. This is due to the two for loops in the program, which gradually increases the

variable, which is written to the servo.

pos

Congratulations! That was just a few easy steps to get started with standard servo motors. Now that you have this working, you can start exploring a lot of different cool projects that uses servo motors, and perhaps start making your very own robot!

Giới thiệu tổng quan về động cơ servo

Có nhiều loại động cơ servo và tính năng chính của chúng là khả năng điều khiển chính xác vị trí của trục. Động cơ servo là một hệ thống vòng kín sử dụng phản hồi vị trí để điều khiển chuyển động và vị trí cuối cùng của nó.

Hệ thống vòng kín

Trong công nghiệp động cơ servo là loại cảm biến phản hồi vị trí, thường là một bộ code hóa có độ chính xác cao, trong khi trong các động cơ RC hoặc nhỏ hơn, cảm biến vị trí thường là một chiết áp đơn giản. Vị trí thực tế được tìm thấy bởi các thiết bị này được đưa trở lại bộ phát hiện lỗi nơi nó được so sánh với vị trí đích. Sau đó, theo lỗi, bộ điều khiển sửa vị trí thực tế của động cơ để khớp với vị trí đích.

Hệ thống vòng kín Servo

Trong hướng dẫn này, chúng tôi sẽ xem xét chi tiết về các động cơ servo thường gặp. Chúng tôi sẽ giải thích cách các servo này hoạt động và cách điểu khiển chúng bằng Arduino.

Động cơ thường dùng là bộ truyền động kích thước nhỏ được sử dụng để điều khiển xe ô tô, thuyền, máy bay, v.v. Chúng cũng được sử dụng bởi các sinh viên kỹ thuật để chế tạo robot, tạo ra cánh tay robot, robot lấy cảm hứng sinh học, robot hình người, v.v.

Ứng dụng động cơ Servo Robot cánh tay Hexapod Robot hình người

⇒ Robot vẽ Axidraw Việt Machine sử dụng động cơ servo: Xem tại đây

Cách thức hoạt động của Servo RC / cổ điển

Bên trong một servo cổ diển có bốn thành phần chính, động cơ DC, hộp số, biến trở và mạch điều khiển. Động cơ DC có tốc độ cao và mô-men xoắn thấp nhưng hộp số giảm tốc độ xuống khoảng 60 vòng / phút, đồng thời tăng mô-men xoắn.

Cách thức hoạt động của Servo bên trong các thành phần Mạch điều khiển chiết áp động cơ DC

Chiết áp được gắn trên bánh răng cuối cùng hoặc trục đầu ra, do đó động cơ cũng quay chiết áp, tạo ra một điện áp liên quan đến góc tuyệt đối của trục đầu ra. Trong mạch điều khiển, điện áp chiết áp này được so sánh với điện áp đến từ đường tín hiệu. Nếu cần, bộ điều khiển kích hoạt mạch cầu H tích hợp cho phép động cơ quay theo hai hướng cho đến khi hai tín hiệu đạt mức chênh lệch bằng không.

Một động cơ servo được điều khiển bằng cách gửi một loạt các xung qua đường tín hiệu. Tần số của tín hiệu điều khiển phải là 50Hz hoặc một chu kỳ xung là 20ms. Độ rộng của xung xác định vị trí góc của servo và các loại servo này thường có thể xoay 180 độ (chúng có giới hạn vật lý khi di chuyển).

Tín hiệu điều khiển động cơ RC Servo

Nói chung các xung có tại 1ms tương ứng với vị trí 0 độ, 1,5ms đến 90 độ và 2ms đến 180 độ. Mặc dù thời gian tối thiểu và tối đa của các xung đôi khi có thể thay đổi theo các loại khác nhau và chúng có thể là 0,5ms cho 0 độ và 2,5ms cho vị trí 180 độ.

Điều khiển động cơ Arduino Servo

Chúng ta hãy kiểm tra những thông tin trên và làm một ví dụ thực tế về điều khiển một servo cổ điển bằng Arduino. Tôi sẽ sử dụng MG996R, một động cơ servo mô-men xoắn cao có bánh răng kim loại với mô-men xoắn 10 kg-cm. Mô-men xoắn cao có dòng ổn định của servo là 2.5A. Dòng điện chạy từ 500mA đến 900mA và điện áp hoạt động từ 4,8 đến 7,2V.

Điều khiển động cơ Arduino Servo MG996R

Xếp hạng hiện tại cho thấy rằng chúng tôi không thể kết nối trực tiếp servo này với Arduino, nên chúng tôi phải sử dụng nguồn điện riêng cho nó. Đây là sơ đồ mạch cho ví dụ này.

Sơ đồ mạch điều khiển Arduino

Chúng ta chỉ cần kết nối chân điều khiển của servo với bất kỳ chân kỹ thuật số nào của board Arduino, kết nối Ground và dây dương với nguồn điện 5V bên ngoài, đồng thời kết nối ground của Arduino với chân GND của servo.

Code điều khiển động cơ Servo từ Arduino

Bây giờ chúng ta hãy xem code Arduino để điều khiển động cơ servo. Code rất đơn giản. Chúng ta chỉ cần xác định chân mà servo được kết nối, xác định chân đó là đầu ra và trong phần vòng lặp tạo ra các xung với chu kỳ và tần số cụ thể như chúng ta đã giải thích ở trên.

#define servoPin 9 void setup() { pinMode(servoPin, OUTPUT); } void loop() { // A pulse each 20ms digitalWrite(servoPin, HIGH); delayMicroseconds(1450); // Duration of the pusle in microseconds digitalWrite(servoPin, LOW); delayMicroseconds(18550); // 20ms – duration of the pusle // Pulses duration: 600 – 0deg; 1450 – 90deg; 2300 – 180deg }

Sau một số thử nghiệm, tôi đã đưa ra các giá trị sau trong khoảng thời gian các xung hoạt động với servo. Các xung có thời lượng 0,6ms tương ứng với vị trí 0 độ, 1,45ms đến 90 độ và 2,3ms đến 180 độ.

Tôi đã kết nối một thiết bị đo vạn năng nối tiếp với servo để kiểm tra dòng điện. Mức dòng điện tối đa mà tôi nhận thấy là lên tới 0,63A. Vâng, bởi vì đây không phải là bản gốc TowerPro MG996R, mà là bản sao rẻ hơn, rõ ràng có hiệu suất kém hơn.

Động cơ Servo MG996R

Tuy nhiên, chúng ta hãy xem một cách thuận tiện hơn để điều khiển các servo bằng Arduino. Đó là sử dụng thư viện Arduino Arduino.

#include

Servo myservo; // create servo object to control a servo void setup() { myservo.attach(9,600,2300); // (pin, min, max) } void loop() { myservo.write(0); // tell servo to go to a particular angle delay(1000); myservo.write(90); delay(500); myservo.write(135); delay(500); myservo.write(180); delay(1500); }

Ở đây chúng ta chỉ cần nạp thư viện, xác định đối tượng servo và sử dụng hàm attach() xác định chân mà servo được kết nối cũng như xác định giá trị tối thiểu và tối đa của thời lượng xung. Sau đó, bằng cách sử dụng hàm write (), chúng ta chỉ cần đặt vị trí của servo từ 0 đến 180 độ. Với thư viện này, chúng ta có thể điều khiển tới 12 servo cùng lúc hoặc 48 servo bằng cách sử dụng board Arduino Mega.

Trình điều khiển PWM / Servo Arduino và PCA9685

Ngoài ra còn có một cách khác để điều khiển servo bằng Arduino và đó là sử dụng trình điều khiển servo PCA9685. Đây là trình điều khiển servo và servo 16 kênh 12 bit, giao tiếp với Arduino bằng bus I2C. Nó có một đồng hồ tích hợp để có thể chạy 16 động cơ cùng lúc, hoặc độc lập với Arduino.

Trình điều khiển Servo Arduino và PCA9685

Chúng ta có thể xâu chuỗi lên tới 62 trình điều khiển này trên cùng một bus I2C. Vì vậy, về mặt lý thuyết, chúng ta có thể điều khiển tới 992 động cơ chỉ bằng hai chân I2C từ board Arduino. 6 chân chọn địa chỉ được sử dụng để đặt địa chỉ I2C khác nhau cho mỗi trình điều khiển bổ sung. Chúng ta chỉ cần kết nối các miếng hàn theo bảng này.

Địa chỉ PCA9685 Chọn Chân Board I2CAddress

Đây là sơ đồ mạch và chúng ta có thể nhận thấy rằng chúng ta cần một nguồn cung cấp điện riêng cho các servo.

Sơ đồ mạch Arduino và PCA9685

Các linh kiện cần thiết
  • Động cơ Servo MG996R
  • Trình điều khiển Servo PCA9685 PWM
  • Board Arduino
  • Nguồn cung cấp điện 5V- 6A DC

=> Nơi bán linh kiện điện tử chất lượng: Xem tại đây

Bây giờ hãy xem code Arduino. Để điều khiển trình điều khiển servo này, chúng ta sẽ sử dụng thư viện PCA9685 có thể tải xuống từ GitHub .

Code Arduino PCA9685

#include

#include “PCA9685.h” PCA9685 driver; // PCA9685 outputs = 12-bit = 4096 steps // 2.5% of 20ms = 0.5ms ; 12.5% of 20ms = 2.5ms // 2.5% of 4096 = 102 steps; 12.5% of 4096 = 512 steps PCA9685_ServoEvaluator pwmServo(102, 470); // (-90deg, +90deg) // Second Servo // PCA9685_ServoEvaluator pwmServo2(102, 310, 505); // (0deg, 90deg, 180deg) void setup() { Wire.begin(); // Wire must be started first Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz driver.resetDevices(); // Software resets all PCA9685 devices on Wire line driver.init(B000000); // Address pins A5-A0 set to B000000 driver.setPWMFrequency(50); // Set frequency to 50Hz } void loop() { driver.setChannelPWM(0, pwmServo.pwmForAngle(-90)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(0)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(90)); delay(1000); }

Trước tiên chúng ta cần bao gồm các thư viện và xác định đối tượng PCA9685. Sau đó, sử dụng đối tượng Servo_Evaluator xác định chu kỳ xung hoặc đầu ra PWM của trình điều khiển. Lưu ý rằng các đầu ra là 12 bit, độ phân giải 4096 bước. Vì vậy, thời gian xung tối thiểu là 0,5ms hoặc 0 độ sẽ tương ứng với 102 bước và thời lượng xung tối đa là 2,5ms hoặc 180 độ ở vị trí 512 bước. Nhưng như đã giải thích trước đó, các giá trị này sẽ được điều chỉnh theo động cơ servo của bạn. Trong trường hợp của tôi, giá trị từ 102 đến 470 tương ứng với vị trí 0 đến 180 độ.

Trong phần thiết lập, chúng ta cần xác định tốc độ xung I2C, đặt địa chỉ trình điều khiển và đặt tần số thành 50Hz.

Trong phần vòng lặp, sử dụng các hàm setChannelPWM () và pwmForAngle (), chúng ta chỉ cần đặt servo theo góc mong muốn.

Tôi đã kết nối một servo thứ hai với trình điều khiển và như tôi dự đoán, nó không ở vị trí giống như ban đầu, và đó là vì các động cơ mà tôi đang sử dụng là bản sao rẻ tiền và chúng không đáng tin cậy. Tuy nhiên, đây không phải là vấn đề lớn vì sử dụng phiên bản Servo_Evaluator, chúng ta có thể đặt các cài đặt đầu ra khác nhau cho mỗi servo. Chúng ta cũng có thể điều chỉnh vị trí 90 độ trong trường hợp nó không bắt đầu ở giữa. Theo cách đó, tất cả các servo sẽ hoạt động như nhau và vị trí góc chính xác.

Điều khiển nhiều servo với trình điều khiển PCA9685

Chúng ta sẽ tới một ví dụ nữa điều khiển nhiều servo với nhiều trình điều khiển PCA9685.

Điều khiển 22 động cơ Servo với Arduino và PCA9685

Với mục đích đó, chúng ta cần kết nối các trình điều khiển với nhau và kết nối địa chỉ phù hợp chọn miếng hàn. Đây là sơ đồ mạch:

Bây giờ chúng ta hãy xem code Arduino

#include

#include “PCA9685.h” PCA9685 driver; // PCA9685 outputs = 12-bit = 4096 steps // 2.5% of 20ms = 0.5ms ; 12.5% of 20ms = 2.5ms // 2.5% of 4096 = 102 steps; 12.5% of 4096 = 512 steps PCA9685_ServoEvaluator pwmServo(102, 470); // (-90deg, +90deg) // Second Servo PCA9685_ServoEvaluator pwmServo2(102, 310, 505); // (0deg, 90deg, 180deg) void setup() { Wire.begin(); // Wire must be started first Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz driver.resetDevices(); // Software resets all PCA9685 devices on Wire line driver.init(B000000); // Address pins A5-A0 set to B000000 driver.setPWMFrequency(50); // Set frequency to 50Hz } void loop() { driver.setChannelPWM(0, pwmServo.pwmForAngle(-90)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(0)); delay(1000); driver.setChannelPWM(0, pwmServo.pwmForAngle(90)); delay(1000); }

Vì vậy, chúng ta nên tạo đối tượng PCA9685 riêng cho từng trình điều khiển, xác định địa chỉ cho từng trình điều khiển cũng như đặt tần số thành 50Hz. Bây giờ chỉ cần sử dụng các hàm setChannelPWM () và pwmForAngle (), chúng ta có thể đặt bất kỳ servo nào ở bất kỳ trình điều khiển nào để định vị bất kỳ góc nào chúng ta muốn.

Dịch từ: https://howtomechatronics.com/how-it-works/how-servo-motors-work-how-to-control-servos-using-arduino/

Mô tơ Servo MG995 là mô tơ servo hạng nặng đáng tin cậy. Nó là một động cơ công suất thấp, hiệu quả về chi phí.

MG995 là thiết kế servo ổ bi kép chống va đập với bánh răng kim loại nên khá khả thi cho sản xuất công nghiệp.

Động cơ có phản ứng nhanh và quay ở tốc độ cao. Nó đi kèm với sức mạnh giữ lớn và dải mô-men xoắn ổn định không đổi.

Chúng được sử dụng rộng rãi trong các dự án chế tạo người máy và sở thích của người tiêu dùng.

Bài đăng này là tổng quan về động cơ và thảo luận về sơ đồ chân, các tính năng, cách làm việc, giao tiếp với Arduino và các ứng dụng của MG995.

MG995 là một động cơ servo ổ bi kép bền bỉ. Sơ đồ hiển thị bên dưới là sơ đồ chân của Động cơ Servo MG995:

Nó là một thiết bị ba đầu cuối. Chi tiết cấu hình pin trong bảng được đề cập dưới đây:

Màu sắc Pin Tên Pin Chi tiết
Red VCC Chân cấp nguồn
Brown GND Tham chiếu Chân điện thế – Kết nối với mặt đất của nguồn điện
Orange PWM Signal Chân đầu vào điều chế độ rộng xung được sử dụng để điều khiển trục quay của động cơ servo MG995

Động cơ được cung cấp năng lượng bằng cách sử dụng các chân nguồn là VCC và GND.

Động cơ Servo MG995 có chân đầu vào tín hiệu để quay động cơ. Nguyên lý làm việc của động cơ này là điều chế độ rộng xung.

Động cơ Servo liên quan chỉ có thể hoạt động ở tần số 50 MHz. Bất kỳ giá trị nào nhiều hay ít đều dẫn đến hỏng hóc thiết bị. Đó là lý do tại sao mỗi chu kỳ của tín hiệu PWM là 20 mili giây.

Vị trí của trục của động cơ phụ thuộc vào chu kỳ làm việc của tín hiệu. Có một số tính toán tiêu chuẩn cho chuyển động quay độ.

Nếu tín hiệu PWM cao hơn 0,5ms trong một chu kỳ, trục sẽ di chuyển về 0 độ. Để xoay trục động cơ đến 90 độ, tín hiệu phải ở mức hơn 1,5ms. Tương tự, tín hiệu thời gian BẬT 2,5ms dẫn đến vị trí trục 180 độ.

Bằng cách này, chúng ta có thể đo và điều khiển động cơ của mình ở các mức độ mong muốn. Để giữ mọi thứ thuận tiện, các thư viện cụ thể được viết để điều khiển và giao diện động cơ thay vì đặt các giá trị PWM mỗi lần.

Trong phần này, chúng ta sẽ học cách giao tiếp động cơ servo SG995 với Arduino. Chúng ta sẽ sử dụng Arduino una trong hướng dẫn này, nhưng bạn có thể sử dụng bất kỳ bảng Arduino nào cung cấp ít nhất một đầu ra tín hiệu PWM. Hơn nữa, hầu hết tất cả board Arduino đều cung cấp tín hiệu PWM.

Kết nối các chân điện áp nguồn của động cơ Servo MG995 với chân 5V và chân GND của Arduino UNO. Điều này sẽ cung cấp năng lượng cho động cơ.

Kết nối chân đầu vào PWM của động cơ với chân đầu ra D6 của Arduino PWM để điều khiển và quay động cơ.

Arduino UNO MG995 Servo Motor
5V VCC
GND GND
D6 PWM pin

Sơ đồ đấu dây để hiển thị các kết nối được cung cấp bên dưới:

/* This example Arduino Sketch controls the complete rotation of * SG995 Servo motor by using its PWM and Pulse width modulation technique */ #include

// include servo library to use its related functions #define Servo_PWM 6 // A descriptive name for D6 pin of Arduino to provide PWM signal Servo MG995_Servo; // Define an instance of of Servo with the name of “MG995_Servo” void setup() { Serial.begin(9600); // Initialize UART with 9600 Baud rate MG995_Servo.attach(Servo_PWM); // Connect D6 of Arduino with PWM signal pin of servo motor } void loop() { Serial.println(“0”);// You can display on the serial the signal value MG995_Servo.write(0); //Turn clockwise at high speed delay(3000); MG995_Servo.detach();//Stop. You can use deatch function or use write(x), as x is the middle of 0-180 which is 90, but some lack of precision may change this value delay(2000); MG995_Servo.attach(Servo_PWM);//Always use attach function after detach to re-connect your servo with the board Serial.println(“0”);//Turn left high speed MG995_Servo.write(180); delay(3000); MG995_Servo.detach();//Stop delay(2000); MG995_Servo.attach(Servo_PWM); }

Cài đặt Thư viện & Khai báo Pin: Để dễ dàng giao tiếp, hãy cài đặt thư viện động cơ servo, tức là “Servo.h”.

Sau đó khởi động lại phần mềm Arduino IDE và đưa nó vào bản phác thảo. Tiếp theo là xác định mã pin.

Chúng ta đã kết nối chân tín hiệu của động cơ với chân PWM 6 của Arduino. Hơn nữa, tạo một phiên bản MG995_Servo của các chức năng thư viện servo.

/* This example Arduino Sketch controls the complete rotation of * SG995 Servo motor by using its PWM and Pulse width modulation technique */ #include

// include servo library to use its related functions #define Servo_PWM 6 // A descriptive name for D6 pin of Arduino to provide PWM signal Servo MG995_Servo; // Define an instance of of Servo with the name of “MG995_Servo”

void setup: Phần void setup khởi tạo giao tiếp Serial với tốc độ truyền chuẩn là 9600 bps. Nó cũng gắn MG995_Servo vào chân 6.

void setup() { Serial.begin(9600); // Initialize UART with 9600 Baud rate MG995_Servo.attach(Servo_PWM); // Connect D6 of Arduino with PWM signal pin of servo motor }

void loop: Phần vòng lặp được mã hóa để quay động cơ theo chiều kim đồng hồ trước rồi ngược chiều kim đồng hồ.

Khi myservowrite (0) được thực thi, động cơ bắt đầu quay từ phía bên phải trong một khoảng thời gian và sau đó dừng lại trong 2000 mili giây.

Tương tự, khi thực thi myservowrite (180), động cơ quay theo hướng ngược chiều kim đồng hồ lại tạm dừng trong 2000 mili giây.

void loop() { Serial.println(“0”);// You can display on the serial the signal value MG995_Servo.write(0); //Turn clockwise at high speed delay(3000); MG995_Servo.detach();//Stop. You can use deatch function or use write(x), as x is the middle of 0-180 which is 90, but some lack of precision may change this value delay(2000); MG995_Servo.attach(Servo_PWM);//Always use attach function after detach to re-connect your servo with the board Serial.println(“0”);//Turn left high speed MG995_Servo.write(180); delay(3000); MG995_Servo.detach();//Stop delay(2000); MG995_Servo.attach(Servo_PWM); }

>>> 100+ Mã Sản Phẩm Dây Rút: https://mecsu.vn/san-pham/day-rut-nhua.5op

>>> 1000+ Mã Sản Phẩm Đầu Cosse: https://mecsu.vn/san-pham/dau-cosse.Q1j

There are many motors to pick from, but it’s important to pick the right one for the job. If your project requires precise positioning, a servo motor is usually the best option. Instruct them where to point, and they’ll do it for you. It’s as simple as that!

They’re useful in a variety of robotics projects, such as steering an RC model’s front wheels or pivoting a sensor on a robotic vehicle.

Arduino Servo Motor Control with Motor Driver Shield L293D
Arduino Servo Motor Control with Motor Driver Shield L293D

Arduino Example 2 – Controlling Servo with a Potentiometer

Our next example involves including a potentiometer so that we can manually adjust the servo’s position. This project can be extremely helpful when controlling the pan and tilt of a sensor connected to a servo.

Wiring

We’ll reuse the wiring from the previous example, but this time we’ll add a 10KΩ potentiometer. Connect one end of the pot to ground, the other to 5V, and the wiper to analog input A0.

Arduino Code

The code for making the servo follow the position of the knob is simpler than the code for making it sweep.


#include

int potPin = 0; int servoPin = 9; Servo servo; void setup() { servo.attach(servoPin); } void loop() { int reading = analogRead(potPin); int angle = map(reading, 0, 1023, 0, 180); servo.write(angle); }

Code Explanation

Notice that a new variable named

potPin

has been introduced.


int potPin = 0;

We start the loop function by reading the value from analog pin A0.


int reading = analogRead(potPin);

The

analogRead()

function returns a value between 0 and 1023. However, we must scale it down because the servo can only rotate 180 degrees.

One method is to use the Arduino map() function, which remaps a number from one range to another. The line below converts the reading to degrees between 0 and 180.


int angle = map(reading, 0, 1023, 0, 180);

Finally, we use the

write()

command to update the servo’s position to the angle selected by the potentiometer.


servo.write(angle);

In the world of electronics and robotics, servo motors play a crucial role in controlling mechanical movements precisely. In this blog post, we’ll delve into the basics of interfacing a servo motor with an Arduino board. Whether you’re a beginner or an experienced enthusiast, this step-by-step guide will help you understand the fundamentals of servo motor control and how to integrate it with an Arduino for your projects. After you have learned the basics you can try other Arduino servo motor projects like this robotic arm using servo motor.

You can also find other such Arduino tutorials and projects on our website.

The components which we will require for this project are

  1. Arduino Uno
  2. USB cable
  3. Servo Motor SG90
  4. Potentiometer 10k ohm
  5. Jumper wires

What is a Servo motor?

A servo motor is a type of motor used in various applications to precisely control the position, speed, and angular rotation of mechanical systems. It’s designed to provide accurate control of its output shaft, allowing for precise angular position control.Servo motors typically consist of a small DC motor, a gear train, a control circuit, and a feedback system. The feedback system, often a potentiometer or an encoder, continuously sends information about the motor’s current position back to the control circuit. This feedback allows the control circuit to adjust the motor’s movement and ensure it reaches and maintains the desired position.

Types of Servo Motors

Servo Motors are divided into two main types

  1. AC Servo Motor
  2. DC Servo Motor

AC Servo motors use an AC power source, these motors use encoders for feedback. They are known for their high-speed and high-torque capabilities, making them suitable for industrial machinery and CNC equipment.DC Servo motors use a DC power source and are often equipped with encoders for feedback. They offer precise control and are commonly used in robotics and small-scale automation.

In this tutorial, we are going to use a DC Servo Motor. If you want to learn more about different types of DC motors in general, You can do that and come back here again.DC Servo Motors are classified into two types

  1. Standard rotation Servo which moves from 0 to 180 degrees
  2. Continuous rotation Servo which moves 360 degrees

We will be using a “Tower pro-Micro Servo sg90 motor” which is a type of DC standard rotation servo motor.

What is Tower Pro SG90 Servo Motor?

The Tower Pro SG90 is a popular and widely used micro servo motor known for its compact size, lightweight design, and affordability. It’s commonly utilized in various hobbyist projects, robotics, remote-controlled vehicles, and small-scale applications that require precise control of angular motion.

Specifications of Tower Pro SG90 Servo Motor

Here are the specifications of a standard SG90 Servo we should know before getting/using a servo motor for your project:

Operating Voltage 4.8 V – 6 V
Stall Torque 1.6 kg-cm
Stall Current 650 mA
Weight 9g
Operating temperature -30 to +60 degree celsius
  • Operating Voltage: This servo motor operates within a voltage range of 4.8V to 6V. Ensure the power supply falls within this range to prevent damage or inefficient operation.
  • Stall Torque: This indicates the maximum torque output of the motor when it’s unable to rotate further. It’s the force the motor can exert at a given voltage, crucial for applications that require the motor to overcome resistance or hold positions against external forces.
  • Stall Current: Stall current refers to the amount of current drawn by a motor when it’s operating at stall or maximum load condition, and the shaft is prevented from rotating. It signifies the maximum current which the motor can draw.
  • Weight: The weight of the servo motor is essential in applications where size and weight constraints are critical, such as in drones, small robotic arms, or RC vehicles.
  • Operating Temperature:Operating temperature refers to the range of temperatures within which a device or component can safely and effectively operate without risking damage or performance degradation.

SG90 Servo Motor Pinout

  • GND Ground (Brown Wire) – This is the ground pin.
  • VCC +5V (Red Wire) – Voltage is supplied to the servo motor through this Pin.
  • Control (Orange Wire) – Through this wire, Position control signals are received via PWM.

Servo Motor Working

A servo motor receives PWM (Pulse Width Modulation) signals to determine its angle of rotation. The PWM signal is a square wave with a variable duty cycle, where the width or duration of the high signal (the “on” time) corresponds to a specific angle. This signal is usually generated by a microcontroller, such as an Arduino.

When the PWM signal is fed to the servo motor’s control input (usually the orange or yellow wire), the motor’s control circuit interprets it as a command to move to a particular angle. The control circuit measures the duration of the high part of the PWM signal, which corresponds to the desired angle. This duration is typically in the range of 1 to 2 milliseconds.

The control circuit then compares this measured duration with the center position (typically 1.5 milliseconds) and adjusts the motor’s shaft to move towards the desired angle. If the duration of the high part of the PWM signal is shorter than the center position, the motor turns in one direction; if it’s longer, the motor turns in the opposite direction.

The servo motor continuously adjusts its position to match the incoming PWM signal. As the duty cycle of the PWM changes, the motor’s shaft rotates accordingly. This closed-loop control mechanism ensures that the motor accurately follows the input signal, allowing for precise and repeatable angular positioning. In essence, the servo motor’s responsiveness to PWM signals enables it to execute controlled movements in various applications, from opening and closing doors to steering remote-controlled vehicles.

In addition to using the microcontroller itself, The Servo Motor can be controlled in various other ways.

Servo Shield: A servo shield is used primarily to simplify and streamline the process of controlling multiple servo motors, particularly when working with microcontroller platforms like Arduino. Here’s how a Servo Shield looks like

Servomotor driver: The Servo drivers or Arduino Servo controller boards are commonly used to control multiple servo motors in various projects, especially in robotics, automation, and lighting systems.The PCA9685 is a popular 16-channel, 12-bit PWM (Pulse Width Modulation) servo driver. We will also learn a proper implementation of controlling multiple servo using PCA9685 later in this blog.

Servo tester: A servo tester is a simple device used to manually test, calibrate, and control servo motors without the need for a microcontroller or complex programming. It’s a standalone tool that allows users to directly interface a servo motor with.

Commonly asked questions about Servo Motors

How does a servo motor differ from a regular DC motor?

Unlike a regular DC motor, a servo motor features a closed-loop control system with feedback mechanisms like potentiometers or encoders. This enables precise position control and makes it stop at a specific angle, whereas a regular DC motor doesn’t inherently have this level of precision.

Why is my servo jittering or not moving smoothly?

Jittering or erratic movement might be due to power issues, noise in the signal, or mechanical restrictions. Ensure a stable power supply, use proper wiring, and ensure the servo isn’t mechanically constrained.

Can I modify a servo motor for continuous rotation?

Yes, some servo models can be modified for continuous rotation by disconnecting the internal feedback mechanism and adjusting the control circuitry. This essentially turns the servo into a geared DC motor with position control disabled.

Circuit Diagram of Interfacing Arduino with Servo Motors and Potentiometer

The below circuit diagram shows how a arduino servo motor control can be done using a potentiometer.

  • Connect the red wire (VCC) of the servo motor to the 5V pin on the Arduino.
  • Connect the brown or black wire (GND) of the servo motor to the GND pin on the Arduino.
  • Connect the orange or yellow wire (Signal) of the servo motor to a digital PWM pin on the Arduino.
  • Connect the positive end of potentiometer to 3.3V pin of Arduino
  • Connect the GND end to the GND pin of Arduino
  • Connect the signal pin to A0 pin(or any analog input pin)

Here’s a pinout of the potentiometer for reference

Servo Motor Arduino Code

The Arduino Servo Library is a software library that simplifies the control of servo motors using Arduino boards. It provides an easy-to-use interface for managing servo motors’ movement and position without the need for intricate programming or handling complex timing functions manually.

To include the Servo Library in your code, you add “#include

” to your code.There are two important example codes which are used for testing the Servo Motor.

Arduino Servo Sweep Code

This test code rotates the servo from 0 degree to 180 degree and then rotates back from 180 to 0 degree without the need of any input from the user side.

#include

This line includes the Servo library, which provides functions and features for controlling servo motors in an Arduino sketch.

Servo myservo;

Here, a servo object named myservo is created using the Servo library. This object will be used to control a servo motor connected to the Arduino. The comment indicates that on most Arduino boards, you can create up to twelve servo objects.

int pos = 0;

An integer variable pos is declared and initialized to store the position of the servo motor.

void setup() { myservo.attach(9);

Within the setup() function, myservo.attach(9); is used to attach the servo object myservo to pin 9 of the Arduino. This line informs the Arduino that the servo is connected to pin 9 and that pin will be used to send control signals to the servo.

void loop() { for (pos = 0; pos <= 180; pos += 1) { myservo.write(pos); delay(15); }

The loop() function contains a for loop that increments the pos variable from 0 to 180 degrees in steps of 1 degree using pos += 1. Inside the loop:

myservo.write(pos);

sends the current position value stored in the pos variable to the servo, commanding it to move to that position.delay(15); pauses the program execution for 15 milliseconds to allow the servo time to reach the specified position.

for (pos = 180; pos >= 0; pos -= 1) { myservo.write(pos); delay(15); }

Following the completion of the first loop, another for loop is used to decrement the pos variable from 180 to 0 degrees in steps of 1 degree using pos -= 1. Inside this loop, the servo is commanded to move to the position specified by the pos variable, and another delay of 15 milliseconds is added between movements.

Here’s how the servo motor tinkercad simulation will look like.

Servo Knob Code

The Arduino knob code is used to control Arduino servo with potentiometer. The code initializes a servo motor on pin 5, reads the analog value from a potentiometer on A0, maps that value to an angle between 0 and 180 degrees, and continuously updates the servo’s position based on the potentiometer’s value. The small delay aids in smooth movement of the servo motor. Here’s the line by line code explantion.you can also find the complete code in the absolute bottom of the blog.

#include

This line includes the necessary library “Servo.h,” which provides functions to control servo motors using the Arduino.

Servo servoMotor;

Here, you’re declaring an object named servoMotor of the Servo class. This object will be used to control the servo motor connected to your Arduino.

void setup() { servoMotor.attach(5); }

The setup() function is a special function that is executed only once when the Arduino board is powered on or reset. Inside the setup() function, you’re using the attach() method of the servoMotor object to connect the servo motor to digital pin 5 on the Arduino. This establishes the communication between the servo motor and the Arduino. The loop() function is another special function that contains the main code to be executed repeatedly.

int potValue = analogRead(A0);

Inside the loop() function, you’re using the analogRead() function to read the analog value from analog pin A0. This value is then stored in the variable potValue.

int servoAngle = map(potValue, 0, 1023, 0, 180);

Here, you’re using the map() function to convert the analog potValue (ranging from 0 to 1023) to a desired servo angle range (0 to 180 degrees). This new value is stored in the variable servoAngle.

servoMotor.write(servoAngle); delay(15); }

The write() method of the servoMotor object is used to set the servo motor’s angle to the calculated servoAngle. A small delay of 15 milliseconds is added using the delay() function. This short delay helps ensure smoother servo motor movement and reduces jitter.

Here’s the servomotor tinkercad simulation which shows how you can control arduino servo with potentiometer

Apart from controlling servo motors with potentiometer, it is also common to control them using push buttons. Previously we have also covered how to control servo motor using push buttons you can check out the link to learn more.

Demonstration of the Project

Here’s how the project output looks like, you can see that in our servo Arduino setup the servo motors is being controlled using the potentiometer.

Controlling multiple Servo Motor using Arduino and PCA9685

The arduino uno has 6 pwm pins only, so you can control upto 6 servo motors using arduino, for more than 6 servo motor control you need to be familiar with a servo motor driver like PCA9686Controlling multiple servo motors using an Arduino and PCA9685 involves using the PCA9685 module as a servo driver, allowing you to control multiple servos simultaneously through the I2C communication protocol. Here’s a circuit diagram that shows the servo Arduino connection for 4 servo motors.

You can use the adafruit PWM Library for this. Just download this library then go to Sketch> Include> Add .Zip library and then guide it to the library download location.When that is completed, go to file>examples> Adafruit PWM Servo Driver Library > gpiotest and upload the code.

Projects using Arduino

Learn how to create a cost-effective Battery Internal Resistance Meter using an Atmel ATtiny85 microcontroller and Arduino platform. Learn step-by-step instructions, schematic diagrams, and coding techniques to accurately measure battery health through internal resistance. Make your electronics projects better with this insightful tool for better battery management and performance optimization.

Arduino Meets TM1637: Display Module Interfacing Simplified! Learn how to easily connect and program the TM1637 4 Digit Seven Segment Display Module with your Arduino. This concise guide covers wiring, coding, and potential applications, making numeric data visualization a breeze for your projects.

Illuminating Projects: Connect TSL25911 Ambient Light Sensor to Arduino! Unveil the magic of light sensing by seamlessly integrating TSL25911 with Arduino. Our guide walks you through wiring, coding, and creative applications, allowing your projects to perceive and respond to light levels effortlessly.

//Simple Arduino Servo Code

//by CircuitDigest

#include

Servo servoMotor;

void setup() {

servoMotor.attach(5);

void loop() {

int potValue = analogRead(A0);

int servoAngle = map(potValue, 0, 1023, 0, 180);

servoMotor.write(servoAngle);

delay(15); // Small delay for smooth movement

Powering Servo Motors

Servo motors have different power requirements depending on their size and the workload they are experiencing. A common servo motor such as the Feetech Mini Servo Motor requires between 4.8 – 6 V at 5 – 6 mA when idle. It doesn’t take very much energy to stand still.

But as soon as the motor starts moving, it starts using more energy, and it gets that energy by pulling more current from the power source.

If it experiences heavier loads such as added weight or an object blocking its movement , it naturally needs to use even more energy to move the obstacle, and as a result the current consumption increases. The current consumption of the motor linked above can reach up to 800 mA.

This high current-draw is generally not safe to draw from an Arduino board. To avoid damaging our board we need to power the servo motor through an external power supply. Choosing the correct power supply depends on the servo motor you are using, so always check the specifications. Pay especially close attention to the:

  • operating voltage range
  • idle current – consumption when not moving
  • running current – consumption when moving freely
  • stall current – consumption under max load or when blocked

To power a 4.8 – 6 V servo you could use a 5 V 1 A AC Adapter, cut the cable, and connect the wires to the servo using e.g. a breadboard.

Note that USB wall chargers are limited to 500 mA (USB 2.0) or 900 mA (USB 3.0).

If your project needs to move around freely without being attached to a power outlet you can also choose batteries to power the servo. If you need 5 V exactly you can use two 18650 Li-Ion batteries together with a step-down converter.

A step-down converter is needed because 18650 Li-Ion batteries will give you around 7.4 V. The max current depends on the specific battery but most of them are designed to output above 1A which is enough to power our small servo.

If you are using bigger or more servos make sure to check your power requirements accordingly.

Capacitors are recommended for powering servo motors. They help stabilize the power supply, minimize voltage drops, and reduce electrical noise. The specific capacitor values may vary based on the servo motor’s requirements, but including them is good practice for better performance and reliability.

When using a Feetech Mini Servo Motor we recommend using a 100 µF capacitor.

Because some capacitors are polarised (meaning that they have a direction), you may need to be careful with how you connect them to your circuit. Make sure to connect them correctly by checking for markings such as a white stripe, a ‘+’ symbol, or a longer lead. If your capacitor has these, match the indicators of the capacitor with your circuit (pay attention to the + and – signs), and be careful not to exceed the voltage limits. This precaution helps prevent issues like leaks or damage that could harm your circuit.

You can read more about capacitors here.

Servo motor controlling with PWM servo motor driver
Servo motor controlling with PWM servo motor driver

Troubleshooting

Servo motor jitters and resets my Arduino board

This is a common problem with these hobby servo motors, the SG90 Micro Servo and the MG996R. The reason for this is that, as mentioned earlier, they can draw quite significant amount of current when they are at load. This can cause the Arduino board to reset, especially if you are powering the servo directly from the Arduino 5V pin.

In order to solve this issue you can use a capacitor across the GND and the 5V pin. It will act as a decouple capacitor which will provide additional current to the system at start up when the DC motor starts.

Servo motor won’t move entire range from 0 to 180 degrees

This is another common problem with these hobby servos. As we explained earlier, a pulse width of 1ms (0.5ms) corresponds to 0 degrees position, and 2ms (2.5ms) to 180 degrees. However, these values can vary from servo to servo and between different manufacturers.

In order to solve this problem, we need to adjust the pulse width we are sending to the servo motor with the Arduino. Luckily, using the Arduino Servo library we can easily adjust the pulse widths values in the attach() function.

The attach() function can take two additional parameters, and that’s the minimum and maximum pulse width in microseconds. The default values are 544 microseconds (0.544milliseconds) for minimum (0 degrees) angle, and 2400 microseconds (2.4ms). So by adjusting these values we can fine tune the moment range of the servo.


myservo.attach(9,600,2300); // (pin, min, max)

Code language: Arduino (arduino)

Servo Motor Control Arduino Code

Now let’s take a look at the Arduino code for controlling the servo motor. The code is very simple. We just need to define the pin to which the servo is connect, define that pin as an output, and in the loop section generate pulses with the specific duration and frequency as we explained earlier.


/* Servo Motor Control - 50Hz Pulse Train Generator by Dejan, https://howtomechatronics.com */ void setup() { pinMode(servoPin, OUTPUT); } void loop() { // A pulse each 20ms digitalWrite(servoPin, HIGH); delayMicroseconds(1450); // Duration of the pusle in microseconds digitalWrite(servoPin, LOW); delayMicroseconds(18550); // 20ms - duration of the pusle // Pulses duration: 600 - 0deg; 1450 - 90deg; 2300 - 180deg }

Code language: Arduino (arduino)

After some testing I came up with the following values for the duration of the pulses that work with my servo. Pulses with 0.6ms duration corresponded to 0 degrees position, 1.45ms to 90 degrees and 2.3ms to 180 degrees.

I connected a multimeter in series with the servo to check the current draw. The maximum current draw that I noticed was up to 0.63A at stall. Well that’s because this isn’t the original TowerPro MG996R servo, but a cheaper replica, which obviously has worse performance.

Nevertheless, let’s take a look at a more convenient way of controlling servos using Arduino. That’s using the Arduino servo library.


/* Servo Motor Control using the Arduino Servo Library by Dejan, https://howtomechatronics.com */ Servo myservo; // create servo object to control a servo void setup() { myservo.attach(9,600,2300); // (pin, min, max) } void loop() { myservo.write(0); // tell servo to go to a particular angle delay(1000); myservo.write(90); delay(500); myservo.write(135); delay(500); myservo.write(180); delay(1500); }

Code language: Arduino (arduino)

Here we just need to include the library, define the servo object, and using the attach() function define the pin to which the servo is connected as well as define the minimum and maximum values of the pulses durations. Then using the write() function we simply set the position of the servo from 0 to 180 degrees.

Turn any DC Motor into a Servo Motor
Turn any DC Motor into a Servo Motor

Arduino Example 1 – Sweep

To get started, we will use one of the Arduino IDE’s built-in examples. Navigate to the Examples sub-menu. Select the Servo and load the Sweep sketch.

Go ahead and upload the sketch. The shaft of your servo motor will begin to sweep back and forth across 180 degrees.


#include

int servoPin = 9; Servo servo; int angle = 0; // servo position in degrees void setup() { servo.attach(servoPin); } void loop() { // scan from 0 to 180 degrees for(angle = 0; angle < 180; angle++) { servo.write(angle); delay(15); } // now scan back from 180 to 0 degrees for(angle = 180; angle > 0; angle--) { servo.write(angle); delay(15); } }

Code Explanation:

Controlling servos is not a simple task, but fortunately, the Arduino IDE already includes a wonderful library called Servo. It contains simple commands that can be used to quickly instruct the servo to rotate to a specific angle.

Therefore, at the beginning of the sketch, we include this library.


#include

Then we declare the Arduino pin to which the servo motor’s control pin is connected.


int servoPin = 9;

The line below creates a servo object.


Servo servo;

You can actually define up to eight servos in this way; for example, if you had two servos, you would write:


Servo servo1; Servo servo2;

The variable

angle

is used to store the servo’s current angle in degrees.


int angle = 0;

In the setup function, we use the following command to link the

servo

object to the control pin of our servo:


servo.attach(servoPin);

The loop function has two

for

loops. The first loop will rotate the motor in one direction, while the second will rotate it in the opposite direction.

The

servo.write(angle)

function instructs the servo to update its position to the specified angle.


servo.write(angle);

Programming the board

To program the board, you will need to have installed the offline editor, or use the online editor. There’s no need to install any external libraries.

Before we begin, let’s take a look at some of the core functions in the program:

  • – includes the Servo library.


    #include

  • – create a servo object.


    Servo myservo

  • – attach the servo to a pin.


    myservo.attach(9)

  • – write a value to the servo (0-180).


    myservo.write(pos)

The code can be found by navigating to File > Examples > Servo > Sweep, or can be copied directly from below. Upload the program to the board.

1#include

23Servo myservo; // create servo object to control a servo4// twelve servo objects can be created on most boards56int pos = 0; // variable to store the servo position78void setup() {9 myservo.attach(9); // attaches the servo on pin 9 to the servo object10}1112void loop() {13 for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees14 // in steps of 1 degree15 myservo.write(pos); // tell servo to go to position in variable ‘pos’16 delay(15); // waits 15ms for the servo to reach the position17 }18 for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees19 myservo.write(pos); // tell servo to go to position in variable ‘pos’20 delay(15); // waits 15ms for the servo to reach the position21 }22}

Closed loop stepper motors -- very impressive
Closed loop stepper motors — very impressive

How Do Servo Motors Work?

You can control the servo motor by sending a series of pulses to it. A typical servo motor expects a pulse every 20 milliseconds (i.e., the signal should be 50Hz).

The length of the pulse determines the position of the servo motor.

  • A short pulse of 1 ms or less will rotate the servo to 0 degrees (one extreme).
  • A pulse duration of 1.5 ms will rotate the servo to 90 degrees (middle position).
  • A pulse duration of 2 ms or so will rotate the servo to 180 degrees (other extreme).

Pulses ranging from 1ms to 2ms will rotate the servo to a position proportional to the pulse width. The animation below will help you understand the relationship between pulses and position.

It is important to note that there is no standard for the exact relationship between pulses and position, so you may need to tweak your sketch to adjust for the range of your servo.

Also, the pulse duration can vary between brands; for example, it might be 2.5ms for 180 degrees and 0.5ms for 0 degrees.

Arduino Servo Motor Control

Let’s put the above said to test and make a practical example of controlling a hobby servo using Arduino. I will use the MG996R which is a high-torque servo featuring metal gearing with stall torque of 10 kg-cm. The high torque comes at a price and that’s the stall current of the servo which is 2.5A. The running current is from 500mA to 900mA and the operating voltage is from 4.8 to 7.2V.

The current ratings indicate that we cannot directly connect this servo to the Arduino, but we must use a separate power supply for it.

Circuit Diagram

Here’s the circuit diagram for this example.

We simply need to connect the control pin of the servo to any digital pin of the Arduino board, connect the Ground and the positive wires to the external 5V power supply, and also connect the Arduino ground to the servo ground.

In case we use a smaller hobby servo, the S90 Micro Servo, it’s possible to power it directly from the 5V Arduino pin.

The S90 Micro Servo has lower current consumption, around 100-200mA no-load running current, but around 500-700mA stall current. On the other hand, the Arduino 5V pin can output only around 500mA if powered via USB, or up to 1A in powered via the barrel connector.

Even though it’s possible to run these 9g servo motors directly to Arduino, for more stable work I would suggest to always use an external power supply for them.

You can get the components needed for this example from the links below:

  • MG996R Servo Motor …………………………. Amazon / Banggood / AliExpress
  • or S90 Micro Servo ………..…………………… Amazon / Banggood / AliExpress
  • Arduino Board ……………………………………. Amazon / Banggood / AliExpress
  • 5V 2A DC Power Supply …………………..….. Amazon / Banggood / AliExpress

Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

Servo Motors, how do they work?
Servo Motors, how do they work?

Standard servo motors

Standard servo motors are actuators that allow for precise control of position (angle). A typical characteristic is that the angle of the motor is 0 – 180 degrees. With other words, it can make one half of a rotation.

A standard servo motor, just as other motors, are essentially just a DC motor, but with some extra features:

  • Control circuit for controlling the motor, e.g. setting the angle.
  • Gears that transform speed into torque, which makes it capable of doing “heavy lifting” at a slower speed, as opposed to a regular DC motor that just spins very fast!
  • Potentiometer that keeps track of its angle. This makes it possible for the servo to “know where it is”.

Take a look at the image below to see how a Servo looks like inside:

The different wires

Almost all servos come with a set of 3 wires. These are PWR, GND and Signal. For a very simple circuit, all that is needed is to connect each of these two pins on the Arduino:

  • PWR (RED) – connects to 5V on the Arduino.
  • GND (BLACK) – connects to GND on the Arduino.
  • Signal (WHITE) – connects to a digital pin on the Arduino (typically 9).

Note: The color combination varies from servo to servo, but typically the red and black remains.

Note: Depending on what Arduino you are using, the signal pin may vary.

Frequently Asked Questions (FAQs)

Using a servo motor with Arduino is quite easy. The servo motor has just 3 wires, two of which are GND and 5V for powering, and the third wire is the control line which goes to the Arduino board.

We can run servo motors directly from Arduino, but we might have power problems. If the servo motor draws more than 500mA of current, the Arduino board might lose it’s power and reset. It’s better to always use a separate power source for the servo motors.

Using the Arduino Servo library we can control up to 12 servo motors with most Arduino boards, and up to 48 servo motors with the Arduino Mega board. Of course, we need to use a dedicated power source for the servo motors.

Hướng dẫn kết nối động cơ AC servo 1Kw Mặt bích 80mm Powmax có phanh từ  - CNC3DS
Hướng dẫn kết nối động cơ AC servo 1Kw Mặt bích 80mm Powmax có phanh từ – CNC3DS

Step 4: More Things About Servos

Controlling servos is easy, and here are a few more tricks we can use:

Controlling the exact pulse time

Arduino has a built-in function servo.write(degrees) that simplifies the control of servos. However, not all servos respect the same timings for all positions. Usually, 1 millisecond means 0 degrees, 1.5 milliseconds mean 90 degrees, and, of course, 2 milliseconds mean 180 degrees. Some servos have smaller or larger ranges.

For better control, we can use the servo.writeMicroseconds(us) function, which takes the exact number of microseconds as a parameter. Remember, 1 millisecond equals 1,000 microseconds.

More servos

In order to use more than one servo, we need to declare multiple servo objects, attach different pins to each one, and address each servo individually. First, we need to declare the servo objects—as many as we need:

// Create servo objects Servo Servo1, Servo2, Servo3;

Then we need to attach each object to one servo motor. Remember, every servo motor uses an individual pin:

Servo1.attach(servoPin1); Servo2.attach(servoPin2); Servo3.attach(servoPin3);

In the end, we just have to address each servo object individually:

Servo1.write(0); // Set Servo 1 to 0 degrees Servo2.write(90); // Set Servo 2 to 90 degrees

Connection-wise, the grounds from the servos go to GND on the Arduino, the servo power to 5V or VIN (depending on the power input), and in the end, each signal line has to be connected to a different digital pin. Contrary to popular belief, servos don’t need to be controlled by PWM pins—any digital pin will work.

Continuous rotation servos

There is a special breed of servos labelled as continuous rotation servos. While a normal servo goes to a specific position depending on the input signal, a continuous rotation servo either rotates clockwise or counter-clockwise at a speed proportional to the signal. For example, the Servo1.write(0) function will make the servomotor spin counter-clockwise at full speed. The Servo1.write(90) function will stop the motor and Servo1.write(180) will turn the motor clockwise at full speed.

There are multiple uses for such servos; however, they are really slow. If you are building a microwave and need a motor to turn the food, this is your choice. But be careful, microwaves are dangerous!

Servo Motor Basics with Arduino

Learn how to connect and control servo motors with your Arduino board.

The Servo Library is a great library for controlling servo motors. In this article, you will find two easy examples that can be used by any Arduino board.

The first example controls the position of an RC (hobby) servo motor with your Arduino and a potentiometer. The second example sweeps the shaft of an RC servo motor back and forth across 180 degrees.

You can also visit the Servo GitHub repository to learn more about this library.

Motor driver shield control (L293D IC)
Motor driver shield control (L293D IC)

What is Servo Motor?

A servo motor is a closed-loop system that uses position feedback to control its motion and final position. There are many types of servo motors and their main feature is the ability to precisely control the position of their shaft.

In industrial type servo motors the position feedback sensor is usually a high precision encoder, while in the smaller RC or hobby servos the position sensor is usually a simple potentiometer. The actual position captured by these devices is fed back to the error detector where it is compared to the target position. Then according to the error the controller corrects the actual position of the motor to match with the target position.

In this tutorial we will take a detailed look at the hobby servo motors. We will explain how these servos work and how to control them using Arduino.

Hobby servos are small in size actuators used for controlling RC toys cars, boats, airplanes etc. They are also used by engineering students for prototyping in robotics, creating robotic arms, biologically inspired robots, humanoid robots and so on.

Step 5: Check Out More

More topics regarding motors such as brushless, transistor drivers ormotor speed control can be found in my Arduino Development Cookbook available here. 😀

Basic servo control

In this tutorial, we will learn how to control a standard servo motor, to go back and forth across 180 degrees, using a `for loop()`. This is done with the help of the Servo library, which is pre-installed library in the Arduino IDE (both offline and online versions).

In this tutorial, we will learn how to control a standard servo motor, to go back and forth across 180 degrees, using a

. This is done with the help of the Servo library, which is pre-installed library in the Arduino IDE (both offline and online versions).

for loop()

Note: This tutorial uses an Arduino UNO, but you can use any official Arduino board.

120Nm 3D Printed Cycloidal Drive
120Nm 3D Printed Cycloidal Drive

Conclusion

Congratulations! That was just a few easy steps to get started with standard servo motors. Now that you have this working, you can start exploring a lot of different cool projects that uses servo motors, and perhaps start making your very own robot!

Feel free to explore the Servo further.

Suggested changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.

License

The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.

Động cơ Servo hoạt động | điều khiển Servo bằng Arduino

LỰA CHỌN ĐỘNG CƠ BƯỚC

Lựa chọn động cơ bước, động cơ servo, động cơ hybrid và một số số phụ kiện đi kèm: Driver điều khiển, phanh từ hay hộp giảm tốc cho động cơ bước ⇒ XEM CÁC LOẠI ĐỘNG CƠ

♦ Xem thêm: Kiến thức về động cơ bước và cách điều khiển

Trong hướng dẫn này, chúng ta sẽ tìm hiểu cách thức hoạt động của động cơ servo và cách điều khiển động cơ servo bằng trình điều khiển PWM Arduino và PCA9685. Bạn có thể xem video sau hoặc đọc hướng dẫn dưới đây.

What is a Servo and what makes it precise?

Servos are motors that allow you to precisely control physical movement because they generally move to a position rather than continuously rotating. They are simple to connect and control because the motor driver is built right into them.

Servos contain a small DC motor connected to the output shaft through gears. The output shaft drives a servo horn and is also linked to a potentiometer (pot).

The potentiometer provides position feedback to the error amplifier in the control unit, which compares the current position of the motor to the target position.

In response to the error, the control unit adjusts the motor’s current position so that it matches the desired position.

In control engineering, this mechanism is known as a servomechanism, or servo for short. It is a closed-loop control system that uses negative feedback to adjust the motor’s speed and direction to achieve the desired result.

How to Control a 12V Motor with Arduino: Easy Wiring & Code Examples
How to Control a 12V Motor with Arduino: Easy Wiring & Code Examples

Servo Motor Pinout

Servo motors typically have three connections, as outlined below.

GND serves as a common ground for the motor and the logic.

5V is a positive voltage that powers the servo.

Control is an input for the control system.

The color of the wires varies between servo motors, but the red wire is always 5V and GND is either black or brown. The control wire is usually orange or yellow.

Step 2: Code

The following code will turn a servo motor to 0 degrees, wait 1 second, then turn it to 90, wait one more second, turn it to 180, and then go back.

// Include the Servo library#include

// Declare the Servo pin int servoPin = 3; // Create a servo object Servo Servo1; void setup() { // We need to attach the servo to the used pin number Servo1.attach(servoPin); } void loop(){ // Make servo go to 0 degrees Servo1.write(0); delay(1000); // Make servo go to 90 degrees Servo1.write(90); delay(1000); // Make servo go to 180 degrees Servo1.write(180); delay(1000); }

If the servo motor is connected on another digital pin, simply change the value of servoPin to the value of the digital pin that has been used.

Attachments

Stepper Motors and Arduino - The Ultimate Guide
Stepper Motors and Arduino – The Ultimate Guide

Step 1: How to Connect Them

A servo motor has everything built in: a motor, a feedback circuit, and most important, a motor driver. It just needs one power line, one ground, and one control pin.

Following are the steps to connect a servo motor to the Arduino:

  1. The servo motor has a female connector with three pins. The darkest or even black one is usually the ground. Connect this to the Arduino GND.
  2. Connect the power cable that in all standards should be red to 5V on the Arduino.
  3. Connect the remaining line on the servo connector to a digital pin on the Arduino.

Check the image for a view of the servo connected to the Arduino.

Keywords searched by users: drive servo motor arduino

How To Control Servo Motors With Arduino - Complete Guide
How To Control Servo Motors With Arduino – Complete Guide
Arduino To Dyn Ac Servo Drive Serial Communication Example - Youtube
Arduino To Dyn Ac Servo Drive Serial Communication Example – Youtube
How To Control Servo Motors With Arduino (3 Examples)
How To Control Servo Motors With Arduino (3 Examples)
16 Channel Servo Motor Control Driver Board For Arduino - Sritu Hobby
16 Channel Servo Motor Control Driver Board For Arduino – Sritu Hobby
Using Servo Motors With Arduino - Youtube
Using Servo Motors With Arduino – Youtube
Servo Motor Interfacing And Control Using Arduino - Geeksforgeeks
Servo Motor Interfacing And Control Using Arduino – Geeksforgeeks
Arduino Servo Motors : 5 Steps (With Pictures) - Instructables
Arduino Servo Motors : 5 Steps (With Pictures) – Instructables
How To Control Servo Motors With Arduino - Complete Guide
How To Control Servo Motors With Arduino – Complete Guide
Using Servo Motors With The Arduino | Dronebot Workshop
Using Servo Motors With The Arduino | Dronebot Workshop
Arduino Servo Motor Control With Motor Driver Shield L293D - Youtube
Arduino Servo Motor Control With Motor Driver Shield L293D – Youtube
Servo Motor Control With An Arduino - Projects
Servo Motor Control With An Arduino – Projects
Servo Motor Speed Control Arduino With 2 Circuits
Servo Motor Speed Control Arduino With 2 Circuits
Using Servo Motors With The Arduino | Dronebot Workshop
Using Servo Motors With The Arduino | Dronebot Workshop
How To Wire And Control An Ac Servo With Arduino: Step-By-Step Guide -  Youtube
How To Wire And Control An Ac Servo With Arduino: Step-By-Step Guide – Youtube
Control 3 Servo Motors (Sg90, Mg995, Mg996R) With 16-Channel Pwm Servo –  Createlabz Store
Control 3 Servo Motors (Sg90, Mg995, Mg996R) With 16-Channel Pwm Servo – Createlabz Store
Servo Motor Interfacing And Control Using Arduino - Geeksforgeeks
Servo Motor Interfacing And Control Using Arduino – Geeksforgeeks
Servo Motor With Arduino Uno R3 : 5 Steps - Instructables
Servo Motor With Arduino Uno R3 : 5 Steps – Instructables
Sg90 Servo Motor Interfacing With Arduino Uno
Sg90 Servo Motor Interfacing With Arduino Uno

See more here: kientrucannam.vn

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *