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

Revision:
2:c3ff024924df
Parent:
1:b12b06e2fc2d
diff -r b12b06e2fc2d -r c3ff024924df main.cpp
--- 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