My version of servo tester for single servo.

Dependencies:   F746_GUI Servo mbed

main.cpp

Committer:
no111u3
Date:
2018-02-12
Revision:
0:d63249ffaef5
Child:
1:63566652d74d

File content as of revision 0:d63249ffaef5:

#include "mbed.h"
#include "Servo.h"
#include "PinNames.h"

Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut led(LED1);

Servo test_servo(D0);

int main()
{
    pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n");
    pc.printf("2,3,4 - Position Servo (full left, middle, full right)\n");
    float position = 0.0f;

    while(1) {
        char c = pc.getc(); // Read hyperterminal
        switch (c) {
            case '0':
                led = 0; // OFF
                break;
            case '1':
                led = 1; // ON
                break;
            case '2':
                position = 0.0f;
                test_servo = position;
                break;
            case '3':
                position = 0.5f;
                test_servo = position;
                break;
            case '4':
                position = 1.0f;
                test_servo = position;
                break;
        }
    }
}