View Single Post
  #2   Spotlight this post!  
Unread 22-02-2012, 15:18
Brian Selle's Avatar
Brian Selle Brian Selle is offline
Mentor
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Texas
Posts: 162
Brian Selle has a spectacular aura aboutBrian Selle has a spectacular aura aboutBrian Selle has a spectacular aura about
Re: Robots can't count: Microswitches

If your pseudo code matches your real code, the module level variable totalBalls defined at:

Quote:
Originally Posted by NS_Radication View Post
Int totalBalls = 2
Will never be updated because the variable totalBalls defined as a argument to your method will take precedence.

Quote:
Originally Posted by NS_Radication View Post
public int microSwitch(int totalBalls)

Try renaming the module level variable to m_totalBalls or another name. Also, you only need to check the upper limit when adding:

If (addball.get() = true and totalBalls < 3
Then totalBalls += 1

And the lower limit when subtracting:

If (minusball.get() = true and totalBalls > 0
Then totalBalls -= 1
Reply With Quote