loading
 
Keyboard control over Lego Mindstorms
mac from United States  [2 posts]
16 year
help! i cant control my lego robot with the following code

keyboard
if x = 1
lego
set x = 0
end if
if x = -1
lego
set x = 0
end if

the code is supposed to tell the rcx to move left when i hit the left arrow key and is supposed to move right when i hit the right arrow key, but instead when i hit either arrow key it does the the robot to move but makes it move indefinately plz help! the following pics show the details in the lego control and the keyboard control.

Anonymous 16 year
Notice the "Clear on Release" checkbox in the keyboard module? If that is checked then the variable will be set to 0 when the key is released ... which is what I think you want.

Also, not sure what the pipeline above is showing as you should only need the Lego and Keyboard module for this to work. What is x above?

STeven.
mac from United States  [2 posts] 16 year
nevermind i got it working, turns out that the if statements were unessary, but the if statements were if the left arrow key was pressed then the value of x would = 1 which would move my robot left

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index