Continuous rotation servo can rotate continuously in both directions. You can not control which angle it is pointing to, but you can control how fast and in what direction it rotates.
Materials
- 1 Arduino Uno board
- 1 Education shield
- 1 continuous rotation servo
Instructions
- Attach the shield onto the top of the Arduino board.
- Attach a servo arm to the continuous rotation servo.
- Connect the continuous rotation servo to D9.
- Connect the board to the computer and upload example ‘ContinuousServo’.
Code
Find the code in Example>EducationShield>Help>ContinuousServo
The servo arm should rotate in one direction. You should now change the speed value in the code and upload it again to make the servo rotate in another speed.
Commands
-
#include <Servo.h>
– includes the Servo library used to control the servos. -
Servo
– creates a servo object. attach( digitalPin )
– attaches the servo to a digital pin.- Parameters
-
(
int
)digitalPin
– the digital pin to which the servo is connected.
-
- Parameters
write( speed )
– makes the continuous rotation servo shaft rotate continuously.- Parameters
- (
int
)speed
– the rotation speed. Can be a value between 0 and 180 where 0 is full speed in one direction and 180 is full speed in the opposite direction.
.
- (
- Parameters
Troubleshooting
- Make sure you have connected the servo to the same pin as you have stated in the code.