My version of servo tester for single servo.
Dependencies: F746_GUI Servo mbed
Diff: main.cpp
- Revision:
- 0:d63249ffaef5
- Child:
- 1:63566652d74d
diff -r 000000000000 -r d63249ffaef5 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 12 17:59:43 2018 +0000 @@ -0,0 +1,39 @@ +#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; + } + } +}