Do not rotate/turn the servo manually! The plastic gears are easily broken.
Servomechanisms, often called "servo motos" or just "servos," are devices that move a rotational axis to a specified angle. An Arduino sketch can be used to control a servo.
Servos are commonly used in radio-controlled model aircraft, cars, etc. to control flight, direction, acceleration and other motion.
Review: Sparkfun Circuit 3A: Servo Motors to learn how PWM (Pulse Width Modulation) is used to control the servo angle.
Use the "set Servo pin" block is in the "Grove Digital" menu to control the servo angle.
Set the pin to "D9" to match the wiring we've completed.
The "delay" value is needed to allow enough time for the servo to reach the selected angle before sending another position. A value of 4 ms. is a good start, but you may need to change the value depending on the specific servo you have.
Create a sketch to:
Move the servo to a specific position. (Simple! Just one block.)
If the servo isn't moving, swap the jumper wires on the outer pins and try again.
Use a Count block to move the servo from 0 to 180 degrees.
Use the Rotary Potentiometer to control the angle of the servo.
Hint: Use the Map block to map the potentiometer value (0-1023) to the servo angle (0-180).
Your ideas?
If you're stuck, here's sketch you can download and open in Codecraft:
Servo.cdc
Servos are controlled by a pulsed signal. The width of the pulse indicates the angle.
The pulse repeats at 50 Hz.
The Arduino servo library generates the needed signal.
Complete: Sparkfun Circuit 3A: Servo Motors
Ignore the "Affix the Servo" section
Use the rotary potentiometer that is on your Grove Beginner kit.
(Note that it is connected to pin A0, same as the Sparkfun experiment.)
The wire colors on your SG90 servo might have different colors. Use this diagram to see the orientation of the wires.
Connect the PWM wire to pin 9 on your Arduino UNO. (right click, open in new window to see this image larger)
After you've got it working, consider the Coding Challenges and change the Arduino sketch to do something else:
Reverse the direction
Try making the servo move in the opposite direction to the potentiometer.
Change the range
Try altering the map function so that moving the potentiometer a lot only moves the servo a little.
Swap in a different sensor
Try swapping a light sensor in for the potentiometer. You have just made a dial that reads how much light is present!