Code to display sensor input of Axis y, If the user presses 'e' then exit the loop. Not working and can not figuer out why

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Nightxp
Date:
Fri Apr 05 19:32:54 2013 +0000
Commit message:
Trying to find out how to skip getchar() when no input is entered

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 05 19:32:54 2013 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "stdio.h"
+ 
+AnalogIn Ac1(p15);  //Accelerometer #1 Y axis
+ 
+float while1 = 0;
+
+float maxTemp;     //Maximum axis value
+float minTemp;     //Minimum axis value
+
+float yAxis;   
+float zAxis;
+
+char c;
+
+int Menu = 1;
+int temp = 0;
+ 
+ while (temp == 1)
+        {
+            yAxis = Ac1;            //yAxis = the analog input pin of AC1
+                
+            if(yAxis > maxTemp)     //Find the maximum value of yAxis
+               maxTemp = yAxis;
+          
+            if(minTemp == 0)        //if yAsix is too low (i.e zero) then reset to the currnt value. (yaxis should never hit 0;)
+                minTemp = yAxis;
+                                
+            if(yAxis < minTemp)     //Find the minimum value of yAxis
+                minTemp = yAxis;
+                    
+            printf("| %0.3f | %0.5f | %0.3f |  %c \r", minTemp, yAxis, maxTemp, c);
+                
+            c = getchar();  //Exit this loop if the user presses 'e'
+            if(c == 'e')
+                temp = 0;
+         }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 05 19:32:54 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file