A serial parser for a specific project

Dependencies:   mbed

Fork of Serial_HelloWorld_Mbed by mbed official

Revision:
6:da101b92bc2d
Parent:
5:1ba2b0e9e582
Child:
7:d25708589910
--- a/main.cpp	Tue Jul 14 14:14:58 2015 +0000
+++ b/main.cpp	Tue Jul 14 14:22:51 2015 +0000
@@ -10,7 +10,7 @@
 Serial pc(TX, RX); // tx, rx
 DigitalOut led(LED1);
  
- int checkDigit(char digit)
+ int isDigit(char digit)
 {
     if (digit >= '0' or digit <= '9')
     {
@@ -28,6 +28,22 @@
     {
         return 1;
     }
+    else
+    {
+        return 0;
+    }
+}
+
+int isAlpha(char c)
+{
+    if( isDigit(c) or isLetter(c) )
+    {
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
 }
 
 int toDigit(char c)
@@ -37,6 +53,10 @@
 
 int main()
 {
+    int motor = 0;
+    int direction = 0;
+    int speed = 0;
+    
     led=1;
     wait(0.5);
     led=0;
@@ -56,18 +76,15 @@
                 
                 char c = pc.getc();// Gets a character from the computer that should be a digit from 0 - 9
                 
-                if (check Digit(c))
-                {
-                    int count = toDigit(c);
+                    //int count = toDigit(c);
                     int x = 0;
                     
-                    while (x < count)
+                    while (x < 3)
                     {
                         pc.printf("%d ", x);
                         x++;
                     }
                     //while loop with counter
-                }
         }
     }
 }
\ No newline at end of file