servos

Dependencies:   Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
m215910
Date:
Fri Oct 12 13:54:00 2018 +0000
Parent:
0:4e3507ef1416
Commit message:
servos;

Changed in this revision

main.cpp Show diff for this revision Revisions of this file
servos.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 4e3507ef1416 -r 46040c1dc16d main.cpp
--- a/main.cpp	Thu Oct 11 04:07:47 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-    
-    
-    //#include "Motor.h" //must change line 31 in Motor.cpp according to Lab
-    #include "mbed.h"
-    #include "Servo.h"
-    
-    
-    float pos = rand()/(float)RAND_MAX; //allows the servo to start at a random position 
-    float pos2 = rand()/(float)RAND_MAX;
-    Servo servo1(p21);
-    Servo servo2(p22);
-    DigitalIn sw1(p16);
-    int sw1state;
-    int i=1;
-    
-    int main() {
-         
-        servo1.calibrate(0.0009, 90.0); //need to calibrate the servos so they don't freak out
-        servo2.calibrate(0.0009, 90.0);
-        servo1=pos; //used to help calibrate
-        servo2=pos2;
-        
-        while(1) {
-        pos=0;
-        pos2=0;
-        sw1state=sw1.read();
-        
-        if((sw1state) == 1) { //if switch is on move servos quickly to other angle
-            servo1 = i;
-            servo2 = i;}
-        if((sw1state) == 0) { //if switch is off move back
-            servo1 = 0;
-            servo2 = 0;}
-            }}
diff -r 4e3507ef1416 -r 46040c1dc16d servos.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/servos.cpp	Fri Oct 12 13:54:00 2018 +0000
@@ -0,0 +1,34 @@
+    
+    
+    //#include "Motor.h" //must change line 31 in Motor.cpp according to Lab
+    #include "mbed.h"
+    #include "Servo.h"
+    
+    
+    float pos = rand()/(float)RAND_MAX; //allows the servo to start at a random position 
+    float pos2 = rand()/(float)RAND_MAX;
+    Servo servo1(p21);
+    Servo servo2(p22);
+    DigitalIn sw1(p16);
+    int sw1state;
+    int i=1;
+    
+    int main() {
+         
+        servo1.calibrate(0.0009, 90.0); //need to calibrate the servos so they don't freak out
+        servo2.calibrate(0.0009, 90.0);
+        servo1=pos; //used to help calibrate
+        servo2=pos2;
+        
+        while(1) {
+        pos=0;
+        pos2=0;
+        sw1state=sw1.read();
+        
+        if((sw1state) == 1) { //if switch is on move servos quickly to other angle
+            servo1 = i;
+            servo2 = i;}
+        if((sw1state) == 0) { //if switch is off move back
+            servo1 = 0;
+            servo2 = 0;}
+            }}