|
Re: Button Help
The latest picture doesn't make it clear which joystick is being read, especially for the top portion.
Anyway, as mentioned before, you really have four possible combinations, three of which you have to define.
Neither button pressed -- motor off (128 for value I guess).
Only J1 pressed -- motor one direction (255)
Only J2 pressed -- motor other direction (0)
Both J1 and J2 pressed -- ??? (may I suggest motor off)
Keep in mind that when you set a motor speed/power, it stays at that setting until you change it. So if you never set it to 128, your motor never stops.
There are many ways to write the logic once you decide what you want. The important thing to do is to walk through your code for each of the above combinations and determine what the result is -- does it match your desired outcome. If it gets too complicated or doesn't seem to do what you want, use probes to verify all your assumptions.
Greg McKaskle
|