Raphaël Drouin
/
number_shower
number_shower
Revision 0:32eca77a10e1, committed 2017-01-11
- Comitter:
- ShaolinPoutine
- Date:
- Wed Jan 11 22:55:04 2017 +0000
- Commit message:
- dfas
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 Wed Jan 11 22:55:04 2017 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); // tx, rx +Serial device(p9, p10); // tx, rx + +int main() { + char msg[4] = {0, 0, 0, 0}; + int i = 0; + while(1) { + if(pc.readable()) { + char c = pc.getc(); + if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) + { + pc.putc(c); + msg[i] = c; + i++; + } + else + { + if (c == '\r') + { + pc.putc(c); + for (i= 0; i < 4 ; i++) + device.putc(msg[i]); + i = 0; + } + } + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jan 11 22:55:04 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/99b5ccf27215 \ No newline at end of file