godai 田中
/
test_timer_servo
this code can not move the servo
Fork of Timer_godai by
Diff: main.cpp
- Revision:
- 1:64fc7f117c1c
- Parent:
- 0:27e1de20d3cb
--- a/main.cpp Wed Feb 13 17:28:57 2013 +0000 +++ b/main.cpp Wed Dec 09 03:25:19 2015 +0000 @@ -1,10 +1,32 @@ #include "mbed.h" Timer t; - -int main() { +Serial pc(USBTX,USBRX); +InterruptIn ch(p18); +PwmOut servo(p26); +//AnalogIn ain(p18); + +double t_read; + +void t_start(){ t.start(); - printf("Hello World!\n"); +} +void t_stop(){ t.stop(); - printf("The time taken was %f seconds\n", t.read()); + t_read = t.read(); + t.reset(); } + +int main(void){ + + pc.baud(115200); + + ch.rise(&t_start); + ch.fall(&t_stop); + +// while(1){ +// pc.printf("%f\r\n",t_read); +// } + + servo.pulsewidth(); +}