Test servo using the serial port.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jmar11
Date:
Sun Oct 12 17:21:05 2014 +0000
Commit message:
First commit.

Changed in this revision

FRDM-TFC.lib Show annotated file Show diff for this revision Revisions of this file
TFC_servo_test.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 4abb1d756ad6 FRDM-TFC.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FRDM-TFC.lib	Sun Oct 12 17:21:05 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Texas-State-IEEE-Robotics/code/FRDM-TFC/#a7cdfa497d52
diff -r 000000000000 -r 4abb1d756ad6 TFC_servo_test.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TFC_servo_test.cpp	Sun Oct 12 17:21:05 2014 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include "TFC.h"
+
+bool isValid(float);
+
+Serial pc(USBTX, USBRX);
+
+int main(){
+    float pos = 0;
+    int deg = 0;
+    uint8_t servo = 0;
+    
+    TFC_Init();
+    
+    pc.printf("Please enter a posiiton for your servo (-1.0-1.0)\r\n");
+    
+    while(1){
+        pc.scanf("%f", &pos);
+        
+        if(isValid(pos)){
+            deg = pos * 90;
+            pc.printf("Your servo is at position %1.3f or %2i degrees  \r", pos, deg);
+            TFC_SetServo(servo, pos);
+        }
+        else{
+            pc.printf("Sorry, invalid command.                         \r");
+            pos = 0;
+            TFC_SetServo(servo, pos);
+        }
+        wait_ms(500);
+    }
+}
+
+bool isValid(float pos){\
+    if (pos <= 1.0f && pos >= -1.0f)
+        return true;
+    else
+        return false;
+}
\ No newline at end of file
diff -r 000000000000 -r 4abb1d756ad6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Oct 12 17:21:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file