arduino servo motors

by:Nyyin     2020-04-21
The servo motor is a good device that can be transferred to a specified position.
Usually, they have a servo arm that can turn 180 degrees.
With Arduino, we can tell the servo system to go to the specified position and it will go to the specified position.
So simple!
First use the servo motor in the remote control (RC)
The world, usually controls the steering of RC cars or the flaps on RC planes.
Over time, they find themselves using robots, automation, and, of course, the Arduino world.
Here we will see how to connect the servo motor and then how to turn it to a different position.
The motor I first connected to Arduino seven years ago was a servo motor.
The nostalgic moment is over, go back to work!
We need the following: there are very few big names in the servo motor world.
Hitec and future ABA are the leading RC servo manufacturers.
Good place to buy their Servocity, Sparkfun and Hobbyking.
All the functions are built into the servo motor: Motor, feedback circuit, and most importantly motor driver.
It requires only one power cord, one ground and one control pin.
Here are the steps to connect the servo motor to the Arduino: view the image of the servo connected to the Arduino.
The following code turns the servo motor to 0 degrees, wait 1 second, then 90 degrees, wait another 1 second, turn to 180 degrees, and then go back.
The servo system is a smart device.
With just one input pin, they can receive the location from the Arduino and then get there.
Inside, they have a motor driver and a feedback circuit that ensures the servo arm reaches the desired position.
But what kind of signal do they receive on the input pin?
It is a flat square wave similar to PWM.
Each cycle in the signal lasts 20 milliseconds, and in most cases the value is low.
At the beginning of each cycle, the signal is at a high level in the time between 1 and 2 milliseconds.
1 ms means 0 degrees and 2 ms means 180 degrees.
Between the two it represents the value between 0-180.
This is a very good and reliable method.
Graphics make it easier to understand.
Keep in mind that using the servo library will automatically disable the PWM function on the Arduino UNO and similar motherboards on PWM pins 9 and 10.
The code simply declares the servo object and then uses the servo to initialize the servo. attach()function.
We should not forget to include the servo Library. In the loop()
, We set the servo to 0 degrees, wait, then set it to 90 degrees, then set it to 180 degrees.
It\'s easy to control the servo system, and we can also use the following tips: Arduino has a built-in
Servo in function. write(degrees)
This simplifies the control of the servo system.
However, not all servo systems respect the same time for all positions.
Usually, 1 millisecond means 0 degrees, 1.
5 milliseconds represent 90 degrees, and of course 2 milliseconds represent 180 degrees.
Some servo systems have a smaller or larger range.
We can use the servo system for better control.
Seconds (us)
Function that takes the exact number of microseconds as a parameter.
Remember that 1 Ms equals 1,000 MS.
In order to use multiple servo, we need to declare multiple servo objects, attach different pins to each servo object, and address each servo object separately.
First, we need to declare the servo object-
We need as much as we need: then we need to connect each object to a servo motor.
Keep in mind that a separate pin is used for each servo motor: Finally, all we need to do is handle each servo object separately: connection-
It is advisable that the servo power be 5 v or VIN from the ground of the servo system to the GND on the Arduino (
Depending on the power input)
Finally, each signal line must be connected to a different digital pin.
Contrary to what is generally believed, the servo system does not need to be controlled by the PWM pin
Any digital pin can work.
There is a special servo system marked as a continuous rotating servo system.
When the normal servo is turned to a specific position according to the input signal, the continuous rotary servo is either rotated clockwise or counter-clockwise
Clockwise at a speed proportional to the signal.
For example, servo1. write(0)
The function will make the servo motor rotate the counter-
Clockwise at full speed. The Servo1. write(90)
The function will stop the motor and servo. write(180)
Turn the motor clockwise at full speed.
There are many uses for this servo system;
However, they are really slow.
This is your choice if you are making a microwave and need a motor to turn the food.
But be careful, the microwave is dangerous!
More topics about motors such as brushless, transistor driver or motor speed control can be found in my Arduino development manual.
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...