User Manual

Test Drive
Lets start by controlling a drive output. You'll need to plug something into the 5V and DRIVE1 terminal blocks. I'm just
using a simple LED with resistor but anything that can be powered by 5V will work.
Note that the drive outputs cannot have 5V output so you must connect the positive pin of whatever you're
driving to 5V. Don't try connecting the positive pin to the drive, and the negative pin to GND, it wont work!
Drive outputs are PWM-able!
This example will show turning the drive output fully on and off once a second:
We start by importing the libraries that we need to have time delays ( import time ) and then the main crickit python
library that will make it super easy to talk to the motors and sensors on crickit ( from adafruit_crickit import crickit )
The crickit object represents the drive outputs available for control. The drives are available on the sub-objects named
drive_1 , drive_2 , drive_3 , drive_4
Note that for the Feather Crickit, these are feather_drive_1 , feather_drive_2 , feather_drive_3 , and
feather_drive_4 .
Set PWM Frequency
Drive outputs are all PWM outputs too, so not only can they turn fully on and off, but you can also set it half-way on. In
general, the default frequency for PWM outputs on seesaw is 1000 Hz, so set the frequency to 1 KHz with
crickit.drive_1.frequency = 1000 . Even if you aren't planning to use the PWM output, please set the frequency!
Note that all the Drive outputs share the same timer so if you set the frequency for one, it will be the same for all of
them.
Control Drive Output
Now that we have a drive pwm object, we can simply assign the PWM duty cycle with the fraction property!
crickit.drive_1.fraction = 0.0 turns the output completely off (no drive to ground, no current draw).
crickit.drive_1.fraction = 1.0 turns the output completely on (fully drive to ground)
And, not surprisingly crickit.drive_1.fraction = 0.5 sets it to 1/2 on and 1/2 off at the PWM frequency set above.
import time
from adafruit_crickit import crickit
print("1 Drive demo!")
crickit.drive_1.frequency = 1000
while True:
crickit.drive_1.fraction = 1.0 # all the way on
time.sleep(0.5)
crickit.drive_1.fraction = 0.0 # all the way off
time.sleep(0.5)
crickit.drive_1.fraction = 0.5 # half on/off
time.sleep(0.5)
# and repeat!
© Adafruit Industries
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-
construction-kit
Page 95 of 201