A servo motor is a special type of motor with internal electronics for control. It can rotate 180 degrees and is controlled using a single wire to tell it the position it should be in. A 50 Hz pulse signal is sent on the line with a varying on-time between 1 and 2 milliseconds corresponding to specific positions of the motor. The motors provided in your kit can move at a rate of 60 degrees in 0.1 seconds. They are typically powered from an external source (not the Arduino's 5V power supply).
Pinout
Note: If you are using more than one servo or a larger servo, you must use an external power supply to provide 5V to the motor. Make sure to connect the ground between the Arduino board and the power supply, so they have a common reference.
This library allows an Arduino board to control hobby servo motors. The Servo library supports up to 12 motors on most Arduino boards. On the Arduino Uno, the library disables analogWrite() PWM functionality on pins 9 and 10, whether or not there is a Servo on those pins.
#include <Servo.h>
Servo myservo;
myservo.attach(pin);
myservo.write(pos);
myservo.read();
https://create.arduino.cc/editor/mjdargen_ncsu/141a1d00-9c5f-45e9-9924-3b218bf70ade/preview
If you want to better control the speed that your servo moves, you can use a function I wrote entitled my_servo_write.
my_servo_write(&servo, pos, speed)
- function to easily move servo controlling the speed and the rotation.&servo
- pointer to servo object to be controlled.pos
- position you would like to move the servo to.speed
- how many milliseconds per degree.Exp: my_servo_write(&myservo, 180, 2);
https://create.arduino.cc/editor/mjdargen_ncsu/2f2d095b-9fb3-4f3b-8ee2-45dd15c3914c/preview