servos

Dependencies:   Servo mbed

Revision:
1:46040c1dc16d
Parent:
0:4e3507ef1416
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;}
-            }}