![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
part1
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:2c98a4766d9f
- Child:
- 1:93eb2c653c86
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 10 20:37:52 2015 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" +#include "string.h" +#include <string> + +//Initialize PWM +PwmOut PWM1(p21); +Serial pc(USBTX, USBRX); + +//Initialize variables that will be used to read +std::string input; + + +int main() +{ + while(1){ + if(pc.readable()) { + char c = pc.getc(); + x = strlen(input); + //If enter is pressed process input + if(c == '\r'){ + //check to see if valid input + if(sizeof(input) == 7){ + pc.printf("%s",input); //print input for debugging + input.clear(); //clear input + } + //mark as invalid input clear data + else{ + input.clear(); //clear input + pc.printf("Invalid Input /n"); //print space + } + } + //Else add the character to current input + else{ + // add character to current input string + input = input + c; + pc.printf("%s\n",input); //print input for debugging + pc.printf("%d",sizeof(input)); + } + wait(0.1); + } + + + + } +} + \ No newline at end of file