code for the RC motor on arm

Dependencies:   Servo mbed

Fork of testrcmotor by Guardians of the Galaxy

Files at this revision

API Documentation at this revision

Comitter:
tsevcik08
Date:
Thu Oct 16 18:53:13 2014 +0000
Parent:
0:88d8a50a003e
Commit message:
Arm servo code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 88d8a50a003e -r a750fbe3305c main.cpp
--- a/main.cpp	Thu Oct 09 18:01:03 2014 +0000
+++ b/main.cpp	Thu Oct 16 18:53:13 2014 +0000
@@ -1,24 +1,37 @@
+//Code for the arm servo
+//Created 09 OCT 14, 3/C Stabler
+//Revised:
+//  16 OCT- Code works, needs smoothing out
 #include "mbed.h"
 #include "Servo.h"
 
-Servo dylan1(p21);
-DigitalIn sw1(p16);
+Servo arm(p21);
+DigitalIn sw1(p16); //up
+DigitalIn sw2(p17); //down
+
+int main(){
 
-int main()
-{
-    float servopos;
-    while (1) {
-        if (sw1 == 1) {
-            for (servopos = 0; servopos <= 1.0; servopos += 1.0) {
-                dylan1 = servopos;
-            }
-            wait (1);
-        } else if (sw1 == 0) {
-            for (servopos = 1.0; servopos >= 0; servopos -=1.0) {
-                dylan1 = servopos;
-            }
-            wait (1);
+    float armpos;
+    
+    while(1){
+       
+       if((sw1 == 1) && (sw2 == 0)){
+           armpos += .05;
+           arm = armpos;
+           wait(.1);
+        }
+        else if((sw1 == 0) && (sw2 == 0)){
+            arm = armpos;
+            wait(.1);
+        }
+        if((sw2 == 1) && (sw1 == 0)){
+            armpos -= .01;
+            arm = armpos;
+            wait(.05);
+        }
+        else if((sw2 == 0) && (sw1 == 0)){
+            arm = armpos;
+            wait(.1);
         }
     }
-}
-
+}
\ No newline at end of file