Posted by Stephen at 1/25/2001 1:57 PM EST
Other on team #122, NASA Knights, from Grafton High School (Robotics team is at NHGS) and NASA.
This post is meant as a programming tip for rookie teams. For the past few years (well, this is what I've been told, this is actually my first year at FIRST) my team has used a button on the robot to reverse the controls; in escence switching the motors you send the certain joystick controls to. This helps to stop the disorientation you get when the robot is turned around and you have to mentally swap everything around. Well, now to the point: as you now, you are only permited 26 varibles in pbasic, and most teams (even mine last year) use a temp variable to swap:
- temp = a
- a = b
- b = temp
but, this wastes a varible. Here is very simple way to swap the varible using bitwise operations:
- a = a ^ b
- b = a ^ b
- a = a ^ b
If you want help understanding the logic, or have problems implementing this code - send me an e-mail at
Steven3554@yahoo.com