Take the 2-minute tour ×
LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. It's 100% free, no registration required.

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
2  
Which programming language is this? –  bungeshea Nov 8 '13 at 5:07
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.