Control the rotation Speed of an AX12 servo (Continuous rotation mode). This program is based on the AX12 API developped by Chris Styles.

Dependencies:   AX12 mbed

Fork of AX12-HelloWorld by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
louali
Date:
Thu Jan 05 09:46:42 2017 +0000
Parent:
1:b12b06e2fc2d
Commit message:
Controling the AX12 Speed (Continuous rotation mode). This programme is based on the AX12 API developped by Chris Styles.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Mar 31 12:03:04 2011 +0000
+++ b/main.cpp	Thu Jan 05 09:46:42 2017 +0000
@@ -3,12 +3,17 @@
 
 int main() {
 
-    AX12 myax12 (p9, p10, 1);
+    AX12 myax12 (p9, p10, 17);
+    myax12.SetMode(1); // Set the mode of the servo: 0 = Positional, default, 1 = Continuous rotation
 
     while (1) {
-        myax12.SetGoal(0);    // go to 0 degrees
-        wait (2.0);
-        myax12.SetGoal(300);  // go to 300 degrees
-        wait (2.0);
+        myax12.SetCRSpeed(1.0); // Set the speed of the servo in continuous rotation mode: 1.0 = full speed clock wise
+        wait (5.0);
+        myax12.SetCRSpeed(0.0); // Set the speed of the servo in continuous rotation mode: 0.0 = Stop
+        wait (5.0);
+        myax12.SetCRSpeed(-1.0); // Set the speed of the servo in continuous rotation mode: - 1.0 = full speed counter clock wise
+        wait (5.0);
+        myax12.SetCRSpeed(0.0); // Set the speed of the servo in continuous rotation mode: 0.0 = Stop
+        wait (5.0);
     }
 }
\ No newline at end of file