Aislinn Probst / Mbed 2 deprecated ServoLab

Dependencies:   Motor Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
probst
Date:
Fri Feb 27 04:21:15 2015 +0000
Commit message:
Part D servo lab;

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
Servo.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 9e14f994576d Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Fri Feb 27 04:21:15 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/balambur/code/Motor/#99e7708a5276
diff -r 000000000000 -r 9e14f994576d Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Fri Feb 27 04:21:15 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 9e14f994576d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Feb 27 04:21:15 2015 +0000
@@ -0,0 +1,67 @@
+// define necessary includes
+#include "mbed.h"
+#include "Motor.h"
+#include "Servo.h"
+#define PULSE .0009
+#define MAX 90
+
+//define the two servos
+Servo servoOne(p21);
+Servo servoTwo(p22);
+
+//define the motor
+Motor m(p23,p24,p25);
+Serial pc(USBTX, USBRX);
+
+
+int main()
+{
+   //calibrate the two servos
+   servoOne.calibrate(PULSE,MAX);
+   servoTwo.calibrate(PULSE,MAX);
+   
+   //declare the initial motor speed
+   double motorSpeed = .1;
+   
+   //set the tow servoes to their initial positions
+   float position = 0;
+   float positionTwo = 1;
+    
+    while(1)
+    {
+      //declare the initial positions
+      servoOne = position;    //0
+      servoTwo = positionTwo; //1
+      
+      //spin the servos in opposite directions forward
+    while(position < 1 && positionTwo > 0)
+      {
+          if(motorSpeed != 1){motorSpeed = motorSpeed + .1;};
+          m.speed(motorSpeed);
+          position = position + .0001;
+          positionTwo = positionTwo - .0001;
+          servoOne = position;
+          servoTwo = positionTwo;
+          
+          
+          wait(.00025);
+          
+      }
+      
+      //spin the servos in opposite positions backwards
+    while(position > 0 && positionTwo < 1)
+    {
+      m.speed(-motorSpeed);
+      position = position - .0001;
+      positionTwo = positionTwo + .0001;
+      servoOne = position;
+      servoTwo = positionTwo;
+      wait(.00025);
+      
+      }
+      
+    
+          
+    }   
+
+}
diff -r 000000000000 -r 9e14f994576d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Feb 27 04:21:15 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac
\ No newline at end of file