Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 27:f51397917a52
- Parent:
- 26:5c966a0a3e8e
- Child:
- 28:71bd4c83c05f
diff -r 5c966a0a3e8e -r f51397917a52 main.cpp
--- 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;
}
}
-
}