do work

Dependencies:   Motor Servo mbed

Revision:
1:040e30c39bee
Parent:
0:41003e98eed8
--- a/main.cpp	Thu Oct 02 17:37:22 2014 +0000
+++ b/main.cpp	Fri Oct 03 12:35:53 2014 +0000
@@ -1,35 +1,37 @@
+// Dylan and Kate *We need to put more here*
+
 #include "mbed.h"
-#include "Motor.h"
-#include "Servo.h"
+#include "Motor.h" // Connect to the DC motor
+#include "Servo.h" // Connect to the Servo motors
 
-Motor kate(p26, p29, p30);
+Motor kate(p26, p29, p30); // Establishing the pins for all of the motors.
 Servo dylan1(p21);
 Servo dylan2(p22);
 
 int main()
 {
-    float servopos;
+    float servopos; // Establish variables for speeds and positions
     float mspeed;
     float nspeed;
-    mspeed= 0.2;
-    nspeed= -0.2;
+    mspeed= 0.2; // Initialize the forward speed of the DC motor
+    nspeed= -0.2; //  Initialize the backward speed of the DC motor
     while (1) {
-        for (servopos = 0; servopos <= 1.0; servopos += 0.02) {
-            dylan1 = servopos;
-            dylan2 = 1.0 - servopos;
-            mspeed = mspeed;
-            kate.speed(mspeed);
+        for (servopos = 0; servopos <= 1.0; servopos += 0.02) { // if the servo is moving "forward"
+            dylan1 = servopos; // Servo 1 is spinning clockwise
+            dylan2 = 1.0 - servopos; // Servo 2 is spinning counterclockwise
+            mspeed = mspeed; // establishes the speed at which the DC motor will spin forward
+            kate.speed(mspeed); // makes the DC motor spin at mspeed
             wait(0.1);
         }
 
-        for (servopos = 1.0; servopos >= 0; servopos -= 0.02) {
-            dylan1 = servopos;
-            dylan2 = 1.0 - servopos;
-            nspeed = nspeed;
-            kate.speed(nspeed);
+        for (servopos = 1.0; servopos >= 0; servopos -= 0.02) { // if the servo is moving "backward"
+            dylan1 = servopos; // Servo 1 is spinning counterclockwise
+            dylan2 = 1.0 - servopos; // Servo 2 is spinning clockwise
+            nspeed = nspeed;// establishes the speed at which the DC motor will spin back
+            kate.speed(nspeed); // makes the DC motor spin at nspeed
             wait(0.1);
         }
-        mspeed = mspeed + 0.1;
-        nspeed = nspeed - 0.1;
+        mspeed = mspeed + 0.1; // increases the speed of the DC motor forward
+        nspeed = nspeed - 0.1; // increases the speed of the DC motor back
     }
 }