We have a built a basic drive train and it is working well. The controller is working fine. We have mounted 2 touch LED’s to the front, and would like them to only turn on when the robot is moving forward. Is there anyway to have the lights only come on when one of the analog sticks is pushed in a certain direction? Thank you for any help or advice.
Yes, this is possible to do in Modkit. The idea behind doing this behavior, is that we first want to check the numerical value of the Controller joystick by using the purple sensing block. If this value is within a desired range, such as all normal forward values, then we’ll light up a touch LED.
The attached code example will check the Controller value of Joystick A 20 times per second. If the Controller axis is pushed forward, it will illuminate green, otherwise it will turn off. The reason why a value of 5 was used instead of zero is because occasionally the joystick will stop just barely off of zero (such as at +1 or -3), which is slow enough to not cause the robot to drive but will appear to a user as perfectly neutral. Thus, using a small deadband helps eliminate an issue of the Touch LED appearing green when the robot isn’t even moving.
You can expand this example code to include different colors for different value ranges by adding more If blocks.