A little code that uses strcmp to compare user input via USB serial
Dependencies: SevenSegLed USBDevice mbed
Revision 0:7b39f2056c89, committed 2014-10-07
- Comitter:
- rantistic
- Date:
- Tue Oct 07 12:44:35 2014 +0000
- Commit message:
- This is a little code that uses strcmp to compare user inputs via USB serial
Changed in this revision
diff -r 000000000000 -r 7b39f2056c89 SevenSegLed.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SevenSegLed.lib Tue Oct 07 12:44:35 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/jf1452/code/SevenSegLed/#2f235ad35a6d
diff -r 000000000000 -r 7b39f2056c89 USBDevice.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Tue Oct 07 12:44:35 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#5bf05f9b3c7b
diff -r 000000000000 -r 7b39f2056c89 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 07 12:44:35 2014 +0000 @@ -0,0 +1,77 @@ +#include "mbed.h" +#include "USBSerial.h" +#include "SevenSegLed.h" + +//Virtual serial port over USB +USBSerial serial; +int countdown; +char userinput[9]; +int x =1; + +int main(void) { + + + while(1) + { + wait(3); + for(countdown = 3; countdown>=0; countdown--) + { + serial.printf("%d\r\n",countdown); + wait(1); + + } + + serial.printf("\nPlease enter your name...\r\n"); + + serial.scanf("%s", &userinput); + wait(1); + + + + if(strcmp("rantistic",userinput) == 0) + { + serial.printf("\n\rThank you, you have entered your name, the program will now return to countdown"); + for(int i =0; i<=3; i++) + { + wait(1); + if(i==3) + serial.printf(".\n"); + else + serial.printf("."); + } + + serial.printf("\n\r"); + + } + + else if(strcmp("milan", userinput) == 0) + { + serial.printf("\n\rMilan is a city...Go home! The program will now return to countdown"); + for(int i =0; i<=3; i++) + { + wait(1); + if(i==3) + serial.printf(".\n"); + else + serial.printf("."); + } + + serial.printf("\n\r"); + } + + else if(strcmp("susan", userinput) == 0) + { + serial.printf("\n\rSusan! What are you still doing here, workaholic...go home!\r\n"); + } + + + else + { + + serial.printf("ERROR, INCORRECT...ur PC is about to crash! Save all work NOW or a massive virus will wipe it all out!\r\n"); + } + + + + } +} \ No newline at end of file
diff -r 000000000000 -r 7b39f2056c89 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 07 12:44:35 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file