CircuitPython for Continuous Servo Motors
You can learn the basics of CircuitPython with Circuit Playground Express here.
With the special Crickit support in CircuitPython, it saves you tons of code and makes it really fast to get started.
For in-depth information on using servo motors with CircuitPython, see this page
Running the Continuous Servo Like a Continuous DC Motor
Here is a simple CircuitPython program that will run one servo connected to Servo 1 (as shown at the top right of this page) at full speed (100%):
import time from adafruit_crickit import crickit # Create one continuous servo on crickit servo port #1 servo = crickit.continuous_servo_1 servo.throttle = 1.0 while True: time.sleep(0.1) # do nothing!
Running Two Continuous Servos on a Chassis
For two continuous servos back to back on a robot chassis, run them forward at full speed by running Servo 1 at 100% and Servo 2 at -100% for 2 seconds then stop:
import time from adafruit_crickit import crickit # Create one continuous servo on crickit servo port #1 left_wheel = crickit.continuous_servo_1 # Create one continuous servo on crickit servo port #2 right_wheel = crickit.continuous_servo_2 while True: # Since the wheels are back-to-back # they have to have opposite rotation direections! left_wheel.throttle = 1.0 right_wheel.throttle = -1.0 time.sleep(2) # move for 2 seconds... # Then stop both wheels left_wheel.throttle = 0 right_wheel.throttle = 0 time.sleep(2) # stop for two seconds... # and repeat!
Mismatched Wheel Speeds
Even continuous servos from the same manufacturer and the same type may rotate at slightly different speeds when set to the exact same speed.
There is a small screw setting in the servo body, unlike standard servos (see picture below). Using a small screwdriver, carefully adjust a servo, say one set to throttle equals zero, to have the motor stopped at that speed.
Page last edited March 08, 2024
Text editor powered by tinymce.