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

main.cpp

Committer:
louali
Date:
2017-01-05
Revision:
2:c3ff024924df
Parent:
1:b12b06e2fc2d

File content as of revision 2:c3ff024924df:

#include "mbed.h"
#include "AX12.h"

int main() {

    AX12 myax12 (p9, p10, 17);
    myax12.SetMode(1); // Set the mode of the servo: 0 = Positional, default, 1 = Continuous rotation

    while (1) {
        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);
    }
}