Hi everyone. We managed to solve the problem of programming the wheels but now we have a new problem; the buttons that are supposed to operate the launching system in our robot don’t really work. I think it might be due to a programming issue. Can anyone tell me how to program the remote so that pressing button 6U will turn on the launching motors while removing releasing your fingers from the button will turn off those motors?
Simplest is going to be
Motor[shooter] =127*vexRT[Btn6U]
If you are using a constant motor power, you can use one of two methods:
const int mtrPwr = 95; //arbitrary constant motor power
void setFly(int pwr) {
motor[fly1] =
motor[fly2] =
motor[fly3] =
motor[fly4] =
pwr;
}
task main() {
while(true) {
if(vexRT[Btn6U]) {
setFly(mtrPwr);
}
else {
setFly(0);
}
}
}
or
const int mtrPwr = 95;
void setFly(int pwr) {
motor[fly1] =
motor[fly2] =
motor[fly3] =
motor[fly4] =
pwr;
}
task main() {
while(true) {
setFly(mtrPwr * vexRT[Btn6U]);
}
}
They do the same thing, although the first is better suited to multiple power settings for different buttons.
I personally use the second method, just because I like using math for logic.
If you are using some kind of velocity control, you can just change the target velocity to 0 or whatever you want it to be.
When the button is pressed, it has a value of 1, and 1 * 127 = 127. When the button is not pressed, it has a value of 0, and 0 * 127 = 0. This means that the motors receive 127 power when the button is pressed, and 0 power when it is not.