LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Controlling Direction

I'm working on this maze I try to make it go forward and once the touch sensor hits to go back a little then turn right slightly and go in reverse. While in reverse turn on the ultrasonic sensor and once its with 10 inches of the wall to turn slightly left and go straight out the maze. The problem is I dont know how to turn off the touch sensor from the "false" statement and hav it go in reverse because it keeps wanting to go straight once going back and turning right.

 

Untitled1.png

Untitled.jpg

 

2.png

 

1.jpg

0 Kudos
Message 1 of 2
(5,848 Views)

Hello Xpac,

 

I've only recently started working with NXT stuff.  But I'll do my best to offer a little help here. 

 

I think there's a problem with your code structure.   With all your Do-While Loops nested like that, the only loop that is going to remain responsive is the innermost loop.  You can see what I mean be creating a little test program with just a boolean control wired to an indicator in each loop.  (you may want to add a Wait timer as well)  

 

When you run it, you'll see that only the inner loop is responsive to inputs.  I think what you really need in this situation is a State Machine.  

 

Have a look around for some of the info on state machines.  There's lots available.  

 

It might seem a little tricky at first to get the structure working for you.  But once you do there will be no looking back.  The state machine is probably the most important construct you can learn in LabVIEW.  

 

Good luck with your project. 

---------------------
Patrick Allen: FunctionalityUnlimited.ca
0 Kudos
Message 2 of 2
(5,837 Views)