Don’t use any while loops in teleop. In robot main, there is a giant while loop around it already, and that won’t go to the next iteration until teleop is completely finished, which could take a while if you have loops inside of it.
For the double solenoid, I’m not sure exactly how they work, but I believe that when you open the solenoid in begin, you have to set the white part under it to be “double”. Then, in teleop, you simply set it to “forward” or “reverse” or “off”
I’m not sure exactly what you want to accomplish with the double solenoid and the joystick, but I’ll assume you want to switch the value whenever it’s pressed. To do that, you’ll have to make a “rising edge trigger”. What this does is that when the value of the button changes from 0 to 1, the “rising edge” of the waveform (if you graph it versus time) is what triggers the output to be true. This will essentially give you a true value when you first touch the button and then wait for the release and repress of the button before outputting another true value. I attached something that will do that.
Once you know when to change it, you can just have another boolean feedback node, which will tell you whether to go forward or backward. When the value of the previous function is true, have it go through a not gate. Then have a select function (or case structure) change the boolean into the enum (the forward/backward thing).
For arcade drive, just take the joystick read and the arcade drive vi and wire up x to x and y to y and the devrefs to the refnum gets.
Having two buttons control which direction a motor goes is slightly tricky. What you need is two select vis, or two case structures. What you want is to read one of the buttons (let’s say the one to go forward). If that is true, send the motor forward. If it’s false, check the other button. If that’s true, send it backwards. if that’s also false, stop the motor.
To have a solenoid directly controlled by a button, just have a button wired to a select/case structure. In the true case, set the solenoid forward, and in the false case set it backwards. Add the joystick button as the input to the case structure.
Ohey that servo code looks familiar :o Anyway, I’d suggest doing the same thing you do for the window motor. However, instead of having the motor go forward, have a fedback node containing the position of the servo and add five to it for the true case.
And finally, we deal with your organization! Yay!! Well, definitely get rid of all the while loops - they’re simply unnecessary. Also, only set the value of each motor/servo/solenoid and only get the value from each input in one place The inputs aren’t as important, but if you try to set the value of the same motor in two different places, the program with set the speed of the motor to one when it runs one of the set outputs, and then as soon as it gets to the other one run it the other way (or stop it!) This is extremely important and you should never, ever do it.
Reading the inputs in one place makes sure that you don’t have the joystick controlling the arm also controlling the drive train (for example). I’ve done that a few times, where I try to raise the arm and then the robot goes shooting forward and kills three people and six cows (don’t ask).
Feel free to PM me if you have any questions, although I probably won’t be able to get back to do for almost a full day.
I hope this helps!
EDIT: Oh, shoot, I only looked at your teleop.vi not the cripper one. The ideas still apply though, just realize I’m referring to the one you posted as teleop.
Rising Edge Trigger.vi (5.26 KB)
Rising Edge Trigger.vi (5.26 KB)