View Single Post
  #3   Spotlight this post!  
Unread 18-02-2014, 13:26
DaveCT DaveCT is offline
Registered User
AKA: Dave Schroeder
FRC #0177 (Bobcats)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Connecticut
Posts: 9
DaveCT is an unknown quantity at this point
Re: Problems with buttons and structures

If you have the false cases setting the motors to zero then you have the same code turning the motors on and turning the motors off. (ie when you press button 2, the first case statement evaluates as false, setting the motors to zero, the second case statement evaluates to true, which tries to turn the motors on) The order of execution is indeterminate in the code you provided which means that you're going to get unpredictable results.

There are a couple of ways to achieve what you want. One would be to nest the two case structures. (check button 2 in the false case of button 1). Another would be to use cascading select blocks to determine which value to send to the Set Motor blocks.

Hope that helps.
__________________
Team 177 | Software Engineer
Reply With Quote