Dependencies:   mbed

Revision:
1:44f0b9d5883b
Parent:
0:2fab16867d73
--- a/strings.cpp	Wed Nov 30 18:06:50 2011 +0000
+++ b/strings.cpp	Wed Dec 14 02:46:16 2011 +0000
@@ -1,11 +1,5 @@
 #include "strings.h"
 
-int    tempEL = 40;
-int    tempA = 40;
-int    tempD = 40;
-int    tempG = 40;
-int    tempB = 40;
-int    tempEH = 40;
 
 //inputs for string detection
 AnalogIn EStringL(p20); 
@@ -16,48 +10,40 @@
 AnalogIn EStringH(p15);
 
 //detection range    
-int bufferVal = 15;
+#define bufferVal 0.5
     
     
 
-char output = 0;
+
 
 char Strings() {
-    
+char toPC=0;    
+int output[] = {-3,-3,-3,-3,-3,-3};
 
- 
-        if(abs(EStringL-tempEL) > bufferVal) {
-           output = (output|0x01); 
-        }else {
-           output = (output&0xFE);
+for(int i=0;i<5;i++){
+        if(EStringL > bufferVal) {
+           output[0] +=1; 
+        }
+        if(AString > bufferVal) {
+            output[1] +=1;
         } 
-        if(abs(AString-tempA) > bufferVal) {
-            output = (output|0x02); 
-        }else {
-         output = (output&0xFD);
-        } 
-       if(abs(DString-tempD) > bufferVal) {
-            output = (output|0x04); 
-        }else {
-          output = (output&0xFB);
+        if(DString > bufferVal) {
+            output[2] +=1; 
         } 
-        if(abs(GString-tempG) > bufferVal) {
-            output = (output|0x08); 
-        }else {
-          output = (output&0xF7);
+        if(GString > bufferVal) {
+            output[3]+=1;
         } 
-       if(abs(BString-tempB) > bufferVal) {
-            output = (output|0x10); 
-        }else {
-          output = (output&0xEF);
+        if(BString > bufferVal) {
+            output[4]+=1;
+        } 
+        if(EStringH > bufferVal) {
+             output[5]+=1;
         } 
-        if(abs(EStringH-tempEH) > bufferVal) {
-             output = (output|0x20); 
-        }else {
-          output = (output&0xDF);
-        } 
-        wait(0.02);
+ }
+    for(int i=0;i<6;i++){
+    if(output[i]>0)
+    toPC+=1<<i;
+    }
     
-    
-    return output;
+    return toPC;
 }
\ No newline at end of file