Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mindstorm NXT Programming Loop Exit Conditions

I am developing a robot for an engineering class. For the purposes of the class I am required to use the NXT programming language. To move, the robot needs to follow a solid black line.

If the robot looses the line, I have it scan to the left for 1 second, or until it reaches a black line. If no line is found it scans to the right for 2 seconds so the initial position is reached then 1 more second or rotation is achieved.

I have the loop set up so that if the line has not been found, the robot continues to move. That runs for a full 1 second time period. If the line is found, motion stops, but the full second still has to complete. Ultimately that means that my program works perfectly, but is really really slow.

tl;dr Is there a way to make loops with two exit condition in the LEGO Mindstorm programming environment? Either after 1 second has elapsed, or a sensor gets the desired input?

like image 548
Nathan Tornquist Avatar asked May 13 '26 06:05

Nathan Tornquist


1 Answers

The last two blocks are Logic blocks set to "OR". In this case, 3 sensors are being watched. If any one is tripped the program drops out of the loop.

.

This is from page 86 of http://www.hightechkids.org/sites/default/files/CoachingLibrary/fll_programming_101_nxt_g.pdf

like image 82
dfrevert Avatar answered May 17 '26 04:05

dfrevert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!