first draft
Dependencies: mbed
Revision 0:5c74277dcb15, committed 2016-03-16
- Comitter:
- openg
- Date:
- Wed Mar 16 00:30:42 2016 +0000
- Commit message:
- first draft;
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 5c74277dcb15 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 16 00:30:42 2016 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" + +InterruptIn encoder(////); + +int count = 0; +int stopCount = 10; +Timer t; +float time; +float countPerSec = 0.0; + +void increment() { + count += 1; +} + +int main() { + encoder.rise(&increment); + while(1) { + if (count >= stopCount) { + t.stop(); + time = t.read(); + countPerSec = float(stopCount) / time; + count = 0; + t.reset(); + t.start(); + } + + } +}
diff -r 000000000000 -r 5c74277dcb15 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 16 00:30:42 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5 \ No newline at end of file