Gets user Input to turn the servo to certain degrees

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
hzelayasolano22
Date:
Mon Jan 14 00:35:57 2019 +0000
Parent:
6:27284b61ae0c
Commit message:
FINISHED and IT WORKS

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.lib Show annotated file Show diff for this revision Revisions of this file
servo.cpp Show annotated file Show diff for this revision Revisions of this file
servo.h Show annotated file Show diff for this revision Revisions of this file
user.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Jan 13 22:33:48 2019 +0000
+++ b/main.cpp	Mon Jan 14 00:35:57 2019 +0000
@@ -9,7 +9,7 @@
     userInit();
     while(1){
         userinput = GetKeyInput();
-        moveservo(userinput);   
+        moveServo(userinput);   
         
      }
 }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Mon Jan 14 00:35:57 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/gokmenascioglu/code/mbed/#a8fa94490a0a
--- a/servo.cpp	Sun Jan 13 22:33:48 2019 +0000
+++ b/servo.cpp	Mon Jan 14 00:35:57 2019 +0000
@@ -1,23 +1,22 @@
 #include "servo.h"
 PwmOut servo(p21);
 
-void setServo();
-    servo.period(0.020);
+void setServo(){
     servo.pulsewidth_us(1500);
     wait(2);
     }
     
 void moveServo(char a){
     switch(a){
-        case 1: servo.pulsdewidth_us(pulsewidth(-90)); break;
-        case 2: servo.pulsdewidth_us(pulsewidth(-67.5)); break;
-        case 3: servo.pulsdewidth_us(pulsewidth(-45)); break;
-        case 4: servo.pulsdewidth_us(pulsewidth(-22.5)); break;
-        case 5: servo.pulsdewidth_us(pulsewidth(0)); break;
-        case 6: servo.pulsdewidth_us(pulsewidth(22.5)); break;
-        case 7: servo.pulsdewidth_us(pulsewidth(45)); break;
-        case 8: servo.pulsdewidth_us(pulsewidth(67.5)); break;
-        case 9: servo.pulsdewidth_us(pulsewidth(90)); break;
+        case 1: servo.pulsewidth_us(pulsewidth(-90)); break;
+        case 2: servo.pulsewidth_us(pulsewidth(-67.5)); break;
+        case 3: servo.pulsewidth_us(pulsewidth(-45)); break;
+        case 4: servo.pulsewidth_us(pulsewidth(-22.5)); break;
+        case 5: servo.pulsewidth_us(pulsewidth(0)); break;
+        case 6: servo.pulsewidth_us(pulsewidth(22.5)); break;
+        case 7: servo.pulsewidth_us(pulsewidth(45)); break;
+        case 8: servo.pulsewidth_us(pulsewidth(67.5)); break;
+        case 9: servo.pulsewidth_us(pulsewidth(90)); break;
         }
     
     }
--- a/servo.h	Sun Jan 13 22:33:48 2019 +0000
+++ b/servo.h	Mon Jan 14 00:35:57 2019 +0000
@@ -1,7 +1,8 @@
 #ifndef SERVO_H
 #define SERVO_H
 #include "mbed.h"
-
+extern PwmOut servo;
 void setServo();
 void moveServo(char a);
-int pulsewidth(int a);
\ No newline at end of file
+int pulsewidth(int a);
+#endif
\ No newline at end of file
--- a/user.h	Sun Jan 13 22:33:48 2019 +0000
+++ b/user.h	Mon Jan 14 00:35:57 2019 +0000
@@ -4,3 +4,4 @@
 
 void userInit();
 char GetKeyInput();
+#endif
\ No newline at end of file