hige dura
/
counter
Revision 0:d266ed1f3d53, committed 2012-07-04
- Comitter:
- higedura
- Date:
- Wed Jul 04 11:18:08 2012 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r d266ed1f3d53 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 04 11:18:08 2012 +0000 @@ -0,0 +1,45 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx +Timer t; +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); +DigitalOut start(p5); +InterruptIn stop(p6); +DigitalIn counter_start(p7); + +void counter(); + +int main() { + + start = 0; + pc.baud(921600); + + led1 = 1; led2 = 1; led3 = 1; led4 = 1; + wait(0.5); led4 = 0; + wait(0.5); led3 = 0; + wait(0.5); led2 = 0; + wait(0.5); led1 = 0; + wait(0.5); + led1 = 1; led2 = 1; led3 = 1; led4 = 1; + + stop.rise(&counter); + + pc.printf("Push button!\r\n"); + while( counter_start==0 ){} + pc.printf("Counter starts!!\r\n"); + start = 1; + t.start(); + + while( start==1 ){} + + printf("The time was taken %f seconds\r\n", t.read()); + +} + +void counter() { + t.stop(); + start = 0; +} \ No newline at end of file
diff -r 000000000000 -r d266ed1f3d53 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jul 04 11:18:08 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4c0c40fd0593