Circuit Python tutorials in Robotics II
View the Project on GitHub MrPrattASH/Robotics-II-Circuit-Python
Lets get more practice using positional servos
Lets take our sweep code and modify it a bit to further discover the differences between a straight set angle, and a sweep. Run both the sweep and basic angle sets in your while True loop. Attach a single servo (positional) to your breadboard and try the following:
#... init statements & servo setup
while True:
# basic angles
print("basic angles")
my_servo.angle = 0 # set the servo to 0 Degrees, the min point
time.sleep(1)
my_servo.angle = 90 # set the servo to 90 Degrees, the midpoint
time.sleep(1)
my_servo.angle = 180 #set the servo to 180 Degrees, the max point
time.sleep(1)
print("sweeps")
for angle in range(0, 180, 5): # "sweep" 0 - 180 degrees, 5 degrees at a time.
my_servo.angle = angle
time.sleep(0.05)
for angle in range(180, 0, -5): # "sweep" 180 - 0 degrees, 5 degrees at a time.
my_servo.angle = angle
time.sleep(0.05)
for angle in range
loops. At what point to you notice a difference between a servo sweep, versus a straight angle? How low can you make the sleep occur to notice a difference?This time, rather than changing our sleep value, we’ll change our angle value each iteration of the loop.
for angle in range(0, 180, 5): # "sweep" 0 - 180 degrees, 5 degrees at a time.
my_servo.angle = angle
time.sleep(0.05)
for angle in range(180, 0, -5): # "sweep" 180 - 0 degrees, 5 degrees at a time.
my_servo.angle = angle
time.sleep(0.05)
for angle in range(0,180,5)
section of the loop, you’ve likely been noticing that our angle is increasing by 5 each iteration.For this challenge, you’ll be making a forklift, table flipping RC rover.
I’m filled with so much rage - Your Rover (probably)
Drive Train:
0 out
your servo: Attach your arm, then rotate your servo horn all the way to the left to achieve 0
degrees on your servo.0*
may not be optimal.10*
optimal? Test this with simple code. Send an angle, and see what the ideal starting point for your arm is90*
optimal? What works for your design?