thirawat chuthong
/
Prac_sent_recei
function joe
Revision 0:6e23fd4c8843, committed 2016-12-02
- Comitter:
- thirawat
- Date:
- Fri Dec 02 07:37:18 2016 +0000
- Commit message:
- function for send and receive position
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 6e23fd4c8843 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 02 07:37:18 2016 +0000 @@ -0,0 +1,57 @@ +#include "mbed.h" + +Serial pc(D1,D0); + +//int char2posit(char cha); +//char posit2char(int posit); + +char posit2char(int posit) +{ + int as = posit+48; + char ch = as; + return ch ; +} + +int char2posit(char cha) +{ + int as = cha; + as = as-48; + return as; +} + +int main() +{ + int i = 53; + char th='h'; + while(1){ + + pc.printf("****ch = %c\n",posit2char(i)); + pc.printf("****int = %d\n\n",char2posit(posit2char(i))); + wait(1); + } +} + + + +/* + char c; + pc.printf("Enter a character: "); + + // Reads character input from the user + pc.scanf("%c", &c); + + // %d displays the integer value of a character + // %c displays the actual character + pc.printf("ASCII value of %c = %d\n\n", c, c); + + + + //int myInt = 48+i; +// +// //scanf("%d", myInt); +// char ch = myInt; +// +// pc.printf("%c = %d\n",ch,myInt); +// i++; +// wait(0.75); +*/
diff -r 000000000000 -r 6e23fd4c8843 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 02 07:37:18 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3 \ No newline at end of file