Dependencies: mbed
Revision 0:414f36d8f87e, committed 2015-11-03
- Comitter:
- ParinyaT
- Date:
- Tue Nov 03 10:12:17 2015 +0000
- Commit message:
- Lab_serial;
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 414f36d8f87e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 03 10:12:17 2015 +0000 @@ -0,0 +1,132 @@ +#include "mbed.h" + +Serial pc(D1, D0); +BusOut LED(D3,D4,D5,D6,D7,D8,D9,D10); + +DigitalIn Logic(D11); +DigitalOut myled(LED1); + +int main() +{ + + uint8_t state_menu=0; + uint8_t state_show=0; + uint8_t state_exit =0; + uint8_t data; + + myled = 0; + pc.printf("Wellcome !\n"); + while(1) { + if(state_show == 0) { + pc.printf("Menu\n"); + pc.printf("1.Running LED \n"); + pc.printf("2.Logic Input Test\n"); + state_show =1; + } + if(pc.readable()) { + data = pc.getc(); + pc.printf("\n"); + state_show =0; + state_exit =0; + + switch(data) { + case '1': + do { + if(state_menu == 0) { + pc.printf("Running LED\n"); + pc.printf("a.Mode 1 \n"); + pc.printf("d.Mode 2 \n"); + pc.printf("s.Stop \n"); + state_menu = 1; + } + if(pc.readable()) { + data = pc.getc(); + pc.printf("\n"); + state_menu=0; + + switch(data) { + + case 'a': + int i = 1; + while(!pc.readable()) { + LED = i; + i = i*2; + if(i>128) i=1; + wait_ms(200); + } + break; + + case 's': + LED =0; + state_exit = 1; + + break; + + case 'd': + i = 128; + while(!pc.readable()) { + LED = i; + i = i/2; + if(i<1) i=128; + wait_ms(200); + } + break; + + default: + pc.printf("plz select a or d\n"); + pc.printf("\n\n"); + break; + + } + } + + + + } while(state_exit ==0); + pc.printf("\n\n"); + break; + + case '2': + + do { + if(state_menu == 0) { + pc.printf("Logic Input Test\n\n"); + + if(Logic){ + pc.printf("Logic is High\n");} + else{ + pc.printf("Logic is Low\n");} + pc.printf("press x to exit or else to continue\n"); + state_menu = 1; + } + if(pc.readable()) { + data = pc.getc(); + if (data == 'x') state_exit = 1; + else state_menu = 0; + } + + + + } while(state_exit ==0); + pc.printf("\n\n"); + break; + + + case 0x00: + + break; + + default: + pc.printf("plz select 1 or 2 only\n"); + pc.printf("\n\n"); + break; + } + } + + + + + + + } +} \ No newline at end of file
diff -r 000000000000 -r 414f36d8f87e mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 03 10:12:17 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file