How to write a Time Out, if a wait sensor just keeps waiting

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
terrycary
Posts: 2
Joined: 22 Sep 2011, 14:49

How to write a Time Out, if a wait sensor just keeps waiting

Post by terrycary »

NXT-G

Flag pole climb and I don't want it getting stuck at the top if the touch sensor misses the cap.

How would you use a timer to change the execution path, or work around it. Any suggestions.
Thanks,
TC
ronmcrae
Posts: 33
Joined: 28 Sep 2010, 14:56

Re: How to write a Time Out, if a wait sensor just keeps waiting

Post by ronmcrae »

terrycary wrote:How would you use a timer to change the execution path, or work around it.
Have you looked into logic variables in NXT-G? One option would be to define a logic variable. Set it to false at the start, and then make the loop that waits for the end condition exit once that variable becomes true.

You'd then need two separate rungs in your program. One would wait for the touch sensor and, when pressed, set the logic variable to true. The other rung could simply do a long (timeout style) wait and when that completes set the variable to true.

Once either rung sets the variable to true the robot can climb back down the pole (or whatever).
terrycary
Posts: 2
Joined: 22 Sep 2011, 14:49

Re: How to write a Time Out, if a wait sensor just keeps waiting

Post by terrycary »

That works. Thanks. New to this and it's conceptually a little different than anything I've programmed in.
TC
ronmcrae
Posts: 33
Joined: 28 Sep 2010, 14:56

Re: How to write a Time Out, if a wait sensor just keeps waiting

Post by ronmcrae »

terrycary wrote:New to this and it's conceptually a little different than anything I've programmed in.
So are you being required to use NXT-G for your project? There are a good number of language options and compilers for the NXT brick. This table gives a decent overview of the main programming options, though some entries are a bit out of date these days.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest