User Manual
More Drivers!
OK that was fun but you want MORE drives right? You can control up to four!
This example is similar to the 1 drive example, but instead of accessing the crickit.drive_1 object directly, we'll make a
list called drives that contains 4 drive objects with
drives = (crickit.drive_1, crickit.drive_2, crickit.drive_3, crickit.drive_4)
Then we can access the individual using drives[0].fraction = 0.5 or iterate through them as we do in the loop. You
don't
have
to do it this way, but its very compact and doesn't take a lot of code lines to create all 4 drives at once!
import time
from adafruit_crickit import crickit
print("4 Drive demo!")
drives = (crickit.drive_1, crickit.drive_2, crickit.drive_3, crickit.drive_4)
for drive in drives:
drive.frequency = 1000
while True:
for drive in drives:
print("Drive #", drives.index(drive)+1)
drive.fraction = 1.0 # all the way on
time.sleep(0.25)
drive.fraction = 0.0 # all the way off
time.sleep(0.25)
# and repeat!
© Adafruit Industries
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-
construction-kit
Page 96 of 201










