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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 21:bef848ac1894
- Parent:
- 20:823f05f5ffd5
--- a/main.cpp Tue Mar 24 15:55:31 2015 +0000
+++ b/main.cpp Wed Mar 25 11:24:16 2015 +0000
@@ -39,7 +39,7 @@
int r_turn_f = 0;
int l_180_f = 0;
int r_180_f = 0;
-int forwards = 0;
+int forward = 0;
int backwards = 0;
int spin = 0;
//Junction Counter (hard coding deccsions on junctions)
@@ -106,21 +106,21 @@
if( l_180_f ) {
set_direction(0x11, 0.2, 0.6); //Needs to test
spin =1; //new state is spin
- forwards = 0;
+ forward = 0;
//start_timer?
} else if (l_turn_f) { //
set_direction(0x01, 0.3,0.3); //CHANGE DUTIES AFTER TESTING
spin =1 ; //reached the end, nothign else matters
- forwards =0;
+ forward =0;
}
} else if(val_l == 7) {
l_turn_f =1;
- if(!forwards) {
- forwards =1;
+ if(!forward) {
+ forward =1;
set_direction(0x11, 0.3,0.3);
- } else if(!forwards) {
- forwards =1;
+ } else if(!forward) {
+ forward =1;
set_direction(0x11, 0.3,0.3);
}
@@ -142,7 +142,7 @@
if (l_turn_f) { //special case ****************************** WON'T HAPPEN**********************
blue.printf("Double Turn?");
set_direction(0x01, 0.3,0.3);
- forwards =0;
+ forward =0;
spin =1;
} else if(l_180_f) {
blue.printf("You've got a junction\n");
@@ -168,15 +168,14 @@
forward = 0;
}
} else if(r_turn_f) {
- set_direction(0x10, 0.3 0.3);
+ set_direction(0x10, 0.3 ,0.3);
forward = 0;
spin = 1;
- } else if {r_180_f) {
+ } else if (r_180_f) {
set_direction(0x11, 0.6, 0.2);
forward = 0;
spin =1;
- }
- else {
+ } else {
r_180_f =1;
}
break;
@@ -226,19 +225,19 @@
default:
//blue.printf("%i\n", val);
set_direction(0x00, 0,0);
- }
}
}
+
/*
//This needed to be completely changed. We need sequential actions, a case statement is too basic (unforetuneately)
led= 0;
switch(val_r) {
case 4: //Normal mode
- if (!forwards) {
+ if (!forward) {
blue.printf("i've got %i on the right\n", val_r);
set_direction(0x11, 0.3,0.3);
- forwards =1;
+ forward =1;
change =1;
break;
}
@@ -246,7 +245,7 @@
blue.printf("i've got %i on the right\n", val_r);
set_direction(0x11, 0.3, 0.2);
- forwards =0;
+ forward =0;
break;
change =1;
@@ -254,16 +253,16 @@
blue.printf("i've got %i on the right\n", val_r);
set_direction(0x11, 0.2, 0.3);
- forwards =0;
+ forward =0;
change =1;
break;
default:
- if (!forwards) {
+ if (!forward) {
blue.printf("i've got %i on the right\n", val_r);
set_direction(0x11, 0.3,0.3);
- forwards =1;
+ forward =1;
break;
}
@@ -271,35 +270,35 @@
if(!change) {
switch(val_l) {
case 2:
- if (!forwards) {
+ if (!forward) {
blue.printf("i've got %i on the left\n", val_l);
set_direction(0x11, 0.3,0.3);
- forwards =1;
+ forward =1;
break;
}
case 3:
blue.printf("i've got %i on the left\n", val_l);
set_direction(0x11, 0.3, 0.2);
- forwards =0;
+ forward =0;
break;
case 1:
blue.printf("i've got %i on the left\n", val_l);
set_direction(0x11, 0.3, 0.2);
- forwards =0;
+ forward =0;
break;
default:
blue.printf("i've got %i on the left\n", val_l);
- if (!forwards) {
+ if (!forward) {
// blue.printf("i've got %i on the left\n", val_l);
set_direction(0x11, 0.3,0.3);
- forwards =1;
+ forward =1;
break;
}
}