nutty
Dependencies: mbed
Revision 0:52cef1cc1434, committed 2017-11-09
- Comitter:
- jnjtnutty
- Date:
- Thu Nov 09 15:37:49 2017 +0000
- Commit message:
- nutty
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 52cef1cc1434 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 09 15:37:49 2017 +0000 @@ -0,0 +1,113 @@ +#include "mbed.h" +BusOut num(D3,D4,D5,D6); +AnalogIn v(A2) ; +Serial tel(D8, D2); + +int main() { + uint8_t data; + float vol; + bool exit = false; + bool show = true; + while(1) + { + if (show == true) + { + tel.printf("------------------------------------\n"); + tel.printf(" Hi! Pitiwut \n"); + tel.printf("------------------------------------\n"); + tel.printf("Menu 1 : Show number\n"); + tel.printf("Menu 2 : Show voltage\n"); + show = false; + } + if (tel.readable()) + { + data = tel.getc(); + show = true; + switch (data) + { + case '1': + tel.printf("insert 0-9 \n"); + tel.printf("exit plz input 'x' \n"); + while (exit == false){ + if (tel.readable()) + { + data = tel.getc(); + switch (data) + { + case '0': + num = 0; + break; + case '1': + num = 1; + break; + case '2': + num = 2; + break; + case '3': + num = 3; + break; + case '4': + num = 4; + break; + case '5': + num = 5; + break; + case '6': + num = 6; + break; + case '7': + num = 7; + break; + case '8': + num = 8; + break; + case '9': + num = 9; + break; + case 'x': + exit = true; + break; + default: + tel.printf("plz input 0-9 \n"); + break; + } + } + } + if (exit == true) + { + exit = false; + break; + } + break; + + case '2': + tel.printf("exit plz input 'x' \n"); + while(exit == false) + { + vol = v.read(); + vol = vol * 3.30f ; + tel.printf("voltage : %.2f \n" , vol); + wait(0.7); + if (tel.readable()) + { + data = tel.getc(); + if (data == 'x') + { + exit = true; + } + else + { + tel.printf("exit plz input 'x' \n"); + } + } + } + if (exit == true) + { + exit = false; + break; + } + } + + } + } +}
diff -r 000000000000 -r 52cef1cc1434 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Nov 09 15:37:49 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/fb8e0ae1cceb \ No newline at end of file