-/* 
-This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
-It won't work with v1.x motor shields! Only for the v2's with built in PWM
-control
+/* door lock test
 
-For use with the Adafruit Motor Shield v2 
+This sketch tests basic functionality of an electric car door lock mechanisim
+using a v2 Adafruit motor shield.
+
+This is a test with a single mechanisim, and uses simple delay() calls to control
+timing.  When multiple devices are being used, the structure will need to change
+to use the current state, and timing information, to perform later operations in
+later passes through void loop().  Similar to the blink without delay example
+code.
+
+For use with the Adafruit Motor Shield v2
 ---->	http://www.adafruit.com/products/1438
 */
 

  myMotor->run(RELEASE);
}

void loop() {  
  Serial.print("tick");
  myMotor->run(FORWARD);
  myMotor->setSpeed(testSpeed);  
  delay(pulseTime);
  myMotor->run(RELEASE);
  //delay(outTime);  

  Serial.print("tock");
  myMotor->run(BACKWARD);
  myMotor->setSpeed(testSpeed);  
  delay(pulseTime);
  myMotor->run(RELEASE);
  delay(inTime);  
}

#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

unsigned const int MOTOR_PORT = 1;

// Timing constants: Tests done with the door lock power directly from the Arduino 5V line.

// Time for (nearly) full travel of the lock mechanisim, at the specified speed
unsigned long const travelTime = 60;//ms
// Speed range is 0 to 255.  For now, full speed for both strike and return
unsigned int const strikeSpeed = 255;
unsigned int const liftSpeed = 255;
// Time to wait after the mechanisim is pulled in (normal 'lock' state)
// This is (will be) the delay after the stick is returned to start, before the
// next beat.
unsigned long const beatDelay = 150;// ms
// The delay at the end of the forward strike, before lifting back up.  This is
// intended to be the time for the stick to bound off of the drum head.
unsigned long const bounceTime = 50;// ms
// In the drum application, the time for one 'beat' cycle, is 2 times the travel time,
// pluss the in and out wait times.

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();

// Select which motor 'port' to use on the shield
Adafruit_DCMotor *myMotor = AFMS.getMotor(MOTOR_PORT);


void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Car Door Lock test for Drumming!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz

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