



#include <Adafruit_MotorShield.h>

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(3);
Adafruit_DCMotor *myMotorTwo = AFMS.getMotor(4);




void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Adafruit Motorshield v2 - DC Motor test!");

  if (!AFMS.begin()) {         // create with the default frequency 1.6KHz
  // if (!AFMS.begin(1000)) {  // OR with a different frequency, say 1KHz
    Serial.println("Could not find Motor Shield. Check wiring.");
    while (1);
  }
  Serial.println("Motor Shield found.");

  // Set the speed to start, from 0 (off) to 255 (max speed)
  myMotor->setSpeed(150);
  myMotor->run(FORWARD);
  // turn on motor
  myMotor->run(RELEASE);

  myMotorTwo->setSpeed(150);
  myMotorTwo->run(FORWARD);
  // turn on motor
  myMotorTwo->run(RELEASE);
}



void loop() {
  
  myMotor->run(BACKWARD);
  myMotor->setSpeed(255);
  delay(3000);

  myMotor->setSpeed(0);
  delay(1000);

  myMotorTwo->run(BACKWARD);
  myMotorTwo->setSpeed(255);
  delay(300);

  myMotorTwo->run(FORWARD);
  myMotorTwo->setSpeed(255);
  delay(100);

  myMotorTwo->setSpeed(0);
  delay(1000);
  
}
