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.

  • 3
    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)
. . .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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