
The servo motor is one of the most widely used motors in Arduino projects that need precise control over a specific angle rather than continuous rotation, and the small SG90 motor is an ideal starting point for learning how this type of motor is controlled.
Components needed
An Arduino Uno board, an SG90 servo motor, and connecting wires.
Wiring it up
The servo motor has just three wires: a power wire (connects to the 5V pin), a ground wire, and a signal wire that connects to a digital pin supporting PWM output, such as pin 10.
How it works
Rather than manually handling the pulse-width modulation details needed to set the servo's angle, the standard Servo library in the Arduino IDE provides a simple abstraction: a Servo object is created and attached to the desired pin via attach(), after which calling write(angle) moves the motor directly to the requested angle, with accepted values ranging from 0 to 180 degrees. In the basic example, the code sweeps the motor gradually from 0 to 180 degrees and back to 0, with a short 15-millisecond delay between each step and the next, giving the motor enough time to actually reach each angle before moving to the following one, so the motion appears smooth rather than jerky.
You can find SG90 servo motors at Juthour Tech.
اترك تعليقا