DC motors are controlled by 4 PWM output pins, the 4 PWM pins let you control speed and direction. And we'll use our seesaw_Motor library to help us manage the throttle (speed) and direction for us, making it very easy to control motors
Note that each DC motor is a little different, so just because you have two at the same throttle does not mean they'll rotate at the exact same speed! Some tweaking may be required
#include "Adafruit_Crickit.h" #include "seesaw_motor.h" Adafruit_Crickit crickit; seesaw_Motor motor_a(&crickit); seesaw_Motor motor_b(&crickit); void setup() { Serial.begin(115200); Serial.println("Dual motor demo!"); if(!crickit.begin()){ Serial.println("ERROR!"); while(1) delay(1); } else Serial.println("Crickit started"); //attach motor a motor_a.attach(CRICKIT_MOTOR_A1, CRICKIT_MOTOR_A2); //attach motor b motor_b.attach(CRICKIT_MOTOR_B1, CRICKIT_MOTOR_B2); } void loop() { motor_a.throttle(1); motor_b.throttle(-1); delay(1000); motor_a.throttle(.5); motor_b.throttle(-.5); delay(1000); motor_a.throttle(0); motor_b.throttle(0); delay(1000); motor_a.throttle(-.5); motor_b.throttle(.5); delay(1000); motor_a.throttle(-1); motor_b.throttle(1); delay(1000); motor_a.throttle(0); motor_b.throttle(0); delay(500); }