View Single Post
  #4   Spotlight this post!  
Unread 01-04-2011, 23:52
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: Same code, but one works, one doesnt.

On the very far left side, you put the three switches into an array, and then did a boolean array to number conversion. That's probably what you want.. however, the output of a 3 input boolean array to number is going to be from 0-7, not 3-5; it's the binary number of the booleans. For five, the number would be from 0 to 2^5 -1 (31).

What you probably want to do is have the case structure run the switch 1 on 1, the switch 2 on 2, the switch 3 on 4, switch 4 on 8 and switch 5 on 16, and then have a "default" case where it does nothing or gives an error - that would mean that either >two or zero switches are pressed.

Also, it's kind of bad form to have so many case structures running off the same input and doing different things that work together, but you probably don't want to mess with that
Reply With Quote