Vincent Ceyssens
/
4180_final_encoder
This is the encoder code
Revision 0:ddf6b258e38a, committed 2017-04-30
- Comitter:
- vceyssens3
- Date:
- Sun Apr 30 23:48:27 2017 +0000
- Commit message:
- This is encoder code;
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Apr 30 23:48:27 2017 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +InterruptIn encoder(p15); +Serial pc(USBTX, USBRX); +int ticker; + +void ticker_func() +{ + ticker++; + +} +int main() { + + encoder.mode(PullUp); + encoder.fall(&ticker_func); + encoder.rise(&ticker_func); + double distance = 0; + + while(1) { + myled=encoder; + distance = double(ticker)*2.5/12; + pc.printf("\r\n distance covered '%i'", ticker); + wait(1); + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Apr 30 23:48:27 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/97feb9bacc10 \ No newline at end of file