Denver / Mbed 2 deprecated denver_train_proj

Dependencies:   mbed TextLCD

Revision:
27:f51397917a52
Parent:
26:5c966a0a3e8e
Child:
28:71bd4c83c05f
--- a/main.cpp	Mon Jun 11 14:34:34 2018 +0000
+++ b/main.cpp	Tue Jun 12 10:32:38 2018 +0000
@@ -98,6 +98,8 @@
 const unsigned int SWBflip_3 = 0x84; //Flip SW3
 const unsigned int SWBflip_4 = 0x88; //Flip SW4
 
+//Array that will keep track of the position of th trains. (-1 = not in track/any other number = sensor where the train is at)
+int pos_trains [2] = {-1,-1};
 
 
 
@@ -175,7 +177,9 @@
 
 
 /**
- Prints the positions where there is a 0
+*
+*Prints the positions where there is a 0
+*
 **/
 
 void printZeros(unsigned int number){
@@ -187,11 +191,14 @@
     */
     
     for(int i=0; i<16;i++){
-        if(~n2 & 1<<i){
+        
+        if(~number & 1<<i){
+            
             cout << "There is a 0 at " << i << endl;
+            pos_trains[1] = pos_trains[0]; 
+            pos_trains[0] = i; 
         }
     }
- 
  }