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

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 0:f6f8cf11779f 1 #include "mbed.h"
chris 0:f6f8cf11779f 2 #include "AX12.h"
chris 0:f6f8cf11779f 3
chris 0:f6f8cf11779f 4 int main() {
chris 0:f6f8cf11779f 5
louali 2:c3ff024924df 6 AX12 myax12 (p9, p10, 17);
louali 2:c3ff024924df 7 myax12.SetMode(1); // Set the mode of the servo: 0 = Positional, default, 1 = Continuous rotation
chris 1:b12b06e2fc2d 8
chris 0:f6f8cf11779f 9 while (1) {
louali 2:c3ff024924df 10 myax12.SetCRSpeed(1.0); // Set the speed of the servo in continuous rotation mode: 1.0 = full speed clock wise
louali 2:c3ff024924df 11 wait (5.0);
louali 2:c3ff024924df 12 myax12.SetCRSpeed(0.0); // Set the speed of the servo in continuous rotation mode: 0.0 = Stop
louali 2:c3ff024924df 13 wait (5.0);
louali 2:c3ff024924df 14 myax12.SetCRSpeed(-1.0); // Set the speed of the servo in continuous rotation mode: - 1.0 = full speed counter clock wise
louali 2:c3ff024924df 15 wait (5.0);
louali 2:c3ff024924df 16 myax12.SetCRSpeed(0.0); // Set the speed of the servo in continuous rotation mode: 0.0 = Stop
louali 2:c3ff024924df 17 wait (5.0);
chris 0:f6f8cf11779f 18 }
chris 0:f6f8cf11779f 19 }