Factory Monitor

Dependencies:   mbed

factory sense HQ

Files at this revision

API Documentation at this revision

Comitter:
melmon
Date:
Tue Oct 06 10:36:10 2015 +0000
Parent:
10:0333f8137979
Commit message:
Values[2] Now counting up, with software enforced inputs - need to try with real hardware

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0333f8137979 -r bcac43b76579 main.cpp
--- a/main.cpp	Fri Sep 11 15:28:50 2015 +0000
+++ b/main.cpp	Tue Oct 06 10:36:10 2015 +0000
@@ -2,7 +2,7 @@
 
 #define no_pins 2
 #define Inputs 0
-#define Outputs 0
+#define Outputs 1
 #define Rejects Values[2]
 
 
@@ -22,19 +22,25 @@
 
 
 int Go_and_check(int a) {
-    sensorState = _pin; // read the sensor input pin:   
-    int zero = 0;            
+    //sensorState = _pin; // read the sensor input pin:   
+    //if (sensorState == 0){sensorState = 1; }
+    //if (sensorState == 1){sensorState = 0; }
+    sensorState = 1;
+    lastSensorState[a] = 0;
+    int zero = 0;         
+    pc.printf("Here = %d\r\n", sensorState);   
         if (sensorState != lastSensorState[a]) // compare the sensorState to its previous state
         {
             // if the state has changed, check to see if it is a change from high to low or low to high             
             if (sensorState == 1){ // if the current state is HIGH then increment the counter
                 lastSensorState[a] = sensorState;
-                pc.printf("sensor state = %d", sensorState);
-                pc.printf("last sensor state= %d", lastSensorState);
+                pc.printf("sensor state = %d\r\n", sensorState);
+                pc.printf("last sensor state= %d\r\n", lastSensorState[a]);
                 return sensorState;
             }
             
             else { // if the current state is LOW then ignore
+                pc.printf("zero = %d \r\n", zero);
                 lastSensorState[a] = sensorState;
                 return zero;
             }
@@ -46,8 +52,6 @@
     DigitalIn _pin;
     int sensorState;
     int lastSensorState[no_pins];
-    
-    
 };
 
 PinCheck inputs(p6);
@@ -55,19 +59,18 @@
 
 int main() {
      
-    int Values[3]; 
-
+    int Values[3] = {0,0,0}; 
 
     while(1)
     {
-        
         for(int i = 0; i < no_pins; i ++){
             if (i == Inputs){ Values[i] += inputs.Go_and_check(i); }
             if (i == Outputs){ Values[i] += outputs.Go_and_check(i); }
+            pc.printf("sensor state = %d \r\n", i);
             
         };
     Rejects = (Inputs - Outputs);
-    pc.printf("go and check %d", Go_and_check);
+    pc.printf("not here = %d \r\n", Values[1]);
     wait(0.2);    
     }
 }
\ No newline at end of file