From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

I cannot stop this while loop

Hello Labview geniuses, 

 

I am new to Labview and I have been assigned a project in which the EV3 is supposed to make a 90 degree turn once it gets to a certain color (in this case, blue), then when it gets to a black line, it is supposed to make another 90 degree turn, then follow this black line, until it reaches another color, which will make it stop. My code is broken up into three parts. The first part is for when the EV3 will use the color sensor to make the two 90 degree turns. The second part is for when the EV3 will use the light sensor to follow the black line. The third part is for when the EV3's color sensor reaches a certain color, making it stop; in this case, blue. The problem I am having has to do with the while loops; I can't seem to stop the while loops, so the code never progresses. I was wondering if anyone could help me because I have tried, what seems to be, EVERYTHING to stop this while loop. 

 

Thank you for any help

0 Kudos
Message 1 of 3
(5,682 Views)

Hey shawnsimon!

 

Could you explain your code a little more please? Thanks!

 

Casey L.

Applications Engineer

0 Kudos
Message 2 of 3
(5,644 Views)

Hey shawnsimon,

There are a couple of right ways to handle this.

The most right way is probably to use a loop that is specific to what you are doing. 

When you drag a loop into a program you will see at the bottom right an infinity sign.  That is because the loop defaults to infinity.  That pretty much means the loop will run until you stop the program, the EV3 powers down, or it runs out of juice. 

The most common way to use a loop is to set it to the type of sensor you are using, like a light sensor, by clicking on the infinity sign.  You will then see all the sensors you can use.  As an example if you set it to a color sensor you will see the three color sensor options you can use to stop the loop.  The simplest is the first: color.  If you select this the icon displays another option: the color(s) of the light you want it to detect.  It defaults to color 5 and shows that color, RED, next to it.  If you click on this you can change it to another single color or to multiple colors.  When the sensor detects the color(s) chosen the loop will stop and the program will move on to the next thing.

Another way to break a loop is to use the LOOP INTERRUPT icon that will stop any loop by using the loop's number (look at the top of each loop to find this number).  This means you can set up a loop that run forever and use the INTERRUPT in another place to stop that loop.  This can be accomplished using more than one program path; essentially something known as parallel processing.

If you click on an icon in your program and hit the F1 key the EV3 HELP system will start up.  You will find the help system to be your best friend.  Locate the information about the loop here.  HELP provides really good examples to show you what you need to know about every icon you can use in the EV3 software...plus lots more. 

It is what I used to learn everything I know : )

Scott

 

0 Kudos
Message 3 of 3
(5,609 Views)