LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

New to NXT software. What I'm trying to do is get my motor to go one of 5 distances, but I'm not sure how to choose between those actions. What I thought of was setting 5 variables to 5 sensors. The idea is that if I activate 1 of 5 sensors (left button, enter button, right button, touch sensor, sound sensor), it will know which of the 5 variables are usable and simply does that.

share|improve this question
Which programming language is this? – shea Nov 8 '13 at 5:07

Yes, global.

5 variables may be 4 more than required. I think one is enough.

Set intSensor = 0
Loop until intSensor > 0
    If leftButton then intSensor = 1
    If rightButton then intSensor = 2    
    If enterButton then intSensor = 3
    If bumped1 then intSensor = 4
    If soundVal > 50 then intSensor = 5
End Loop
If intSensor = 1 then moveForward(135)
. . .
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.