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.
Revision 2:d125202709f3, committed 2019-01-09
- Comitter:
- Crossroad
- Date:
- Wed Jan 09 01:16:28 2019 +0000
- Parent:
- 1:38c113df41e1
- Commit message:
- light
Changed in this revision
| Light.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Light.h Tue Jan 08 08:22:08 2019 +0000
+++ b/Light.h Wed Jan 09 01:16:28 2019 +0000
@@ -1,5 +1,5 @@
///点灯///
-
+int State;
DigitalOut NorthStraightRed(PC_9);
DigitalOut NorthStraightYellow(PB_8);
DigitalOut NorthStraightGreen(PB_9);
@@ -13,7 +13,10 @@
DigitalOut WestLeftYellow(PB_14);
DigitalOut WestLeftGreen(PB_13);
void Light(){
- for(int i=1;i<9;i++){
+ State=1;
+ while(1){
+ int i=State%9;
+ State++;
switch(i){
case '1': NorthStraightRed=0;
NorthStraightGreen=1;
@@ -28,6 +31,7 @@
WestLeftYellow=0;
WestLeftGreen=0;
wait(5);
+ break;
case '2': NorthStraightRed=0;
NorthStraightGreen=0;
NorthStraightYellow=1;
@@ -41,6 +45,7 @@
WestLeftYellow=0;
WestLeftGreen=0;
wait(2);
+ break;
case '3': NorthStraightRed=1;
NorthStraightGreen=0;
NorthStraightYellow=0;
@@ -54,6 +59,7 @@
WestLeftYellow=0;
WestLeftGreen=0;
wait(5);
+ break;
case '4': NorthStraightRed=1;
NorthStraightGreen=0;
NorthStraightYellow=0;
@@ -67,6 +73,7 @@
WestLeftYellow=0;
WestLeftGreen=0;
wait(2);
+ break;
case '5': NorthStraightRed=1;
NorthStraightGreen=0;
NorthStraightYellow=0;
@@ -80,6 +87,7 @@
WestLeftYellow=0;
WestLeftGreen=0;
wait(5);
+ break;
case '6': NorthStraightRed=1;
NorthStraightGreen=0;
NorthStraightYellow=0;
@@ -93,6 +101,7 @@
WestLeftYellow=1;
WestLeftGreen=0;
wait(2);
+ break;
case '7': NorthStraightRed=1;
NorthStraightGreen=0;
NorthStraightYellow=0;
@@ -106,6 +115,7 @@
WestLeftYellow=0;
WestLeftGreen=1;
wait(5);
+ break;
case '8': NorthStraightRed=0;
NorthStraightGreen=0;
NorthStraightYellow=1;
@@ -119,7 +129,8 @@
WestLeftYellow=1;
WestLeftGreen=0;
wait(2);
+ break;
default:break;
+ }
}
- }
}
\ No newline at end of file