Diplomarbeit Augimeter
/
Servo_versuch
Servo_versuch
Revision 0:0edb70dfa322, committed 2017-09-14
- Comitter:
- Jannis
- Date:
- Thu Sep 14 07:37:50 2017 +0000
- Commit message:
- Servo_versuch
Changed in this revision
diff -r 000000000000 -r 0edb70dfa322 Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Thu Sep 14 07:37:50 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 0edb70dfa322 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 14 07:37:50 2017 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" +#include "Servo.h" + +Servo myservo(p26); +Serial pc(USBTX, USBRX); + +int main() { + + pc.baud(4800); + + printf("Servo Calibration Controls:\n"); + printf("1,2,3 - Position Servo (full left, middle, full right)\n"); + printf("4,5 - Decrease or Increase range\n"); + + float range = 0.0005; + float position = 0.5; + + while(1) { + switch(pc.getc()) { + case '1': position = 0.005; break; + case '2': position = 0.502; break; + case '3': position = 1.050; break; + case '4': range += 0.0001; break; + case '5': range -= 0.0001; break; + case '6': position = 0.005; + while (position < 1.0) + { + position += 0.001; + wait_ms(25); + myservo = position; + + float wert = myservo.read(); + printf("read: %.3f", wert); + + if (position >= 0.998) + position = 0.0; + } + + break; + + } + printf("position = %.1f, range = +/-%0.4f\n", position, range); + myservo.calibrate(range, 90.0); + myservo = position; + float wert = myservo.read(); + printf("read: %.3f", wert); + + } +} \ No newline at end of file
diff -r 000000000000 -r 0edb70dfa322 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 14 07:37:50 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6 \ No newline at end of file