|
Re: Problem programming buttons
If I understand what you're describing, you have four essentially independent Case Structures. Each of them sets the same motors in the True case. What do the False cases do? It sounds like they all set the motors to zero.
I think you've made a common programming error. If the second button is pressed, its True case sets the motors to the value you want -- but because the first button is not pressed, its False case immediately sets the motors to zero. Having multiple Motor Set functions is a recipe for this sort of race condition.
Instead of having the Case do everything, just have it produce the values you want to run the motor with, and put a single RefNum Get and Motor Set Value outside the Case Structures. Chain the Case Structures together so that the False case just feeds its inputs straight through to its outputs without change, and the True case ignores the inputs and wires the desired constants to its outputs. Feed zeros into the first Case Structure so that the motors will be off when no buttons are pressed.
Or you can use Select functions instead of Case structures.
Or you can get fancy and encode the four buttons into a number, then use that number to select among many different Cases in a single structure.
|