Relatively new to VEXcodePro V5 and C++, so bare with me. I have some kids who have built a duck hunt shooting gallery game. They have a tank tread conveyor belt with ducks on it, and a limit switch behind each duck. They want the tread to move back and forth for a duration of time, and each time a duck is hit (limit switch tiggered) a different motor (image of the hunter) moves up and down in celebration. The hunter is taped to a cam and follower. The program works, but only when the limit switches are pressed for over a second. How can they get the limit switches to work when they are triggered, not held down?
here is the program.
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// water motor 1
// dave motor 2
// bumperA bumper A
// duck1 limit C
// duck2 limit D
// duck3 limit E
// ---- END VEXCODE CONFIGURED DEVICES ----
#include "vex.h"
using namespace vex;
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
while(true){
//once bumper is pressed, the tread begins reciprical movement back and forth
if(bumperA.pressing()){
//moves ducks on tread back and forth a total of 15 seconds, Dave the hunter (cam/follower) moves up and down at the low rpm.
repeat(10){
dave.spin(forward);
dave.setVelocity(25,rpm);
water.spin(forward);
wait(.7, seconds);
water.stop();
water.spin(reverse);
wait(.7, seconds);
water.stop();
dave.stop();
// if duck 1,2,or 3 (limit switches) are hit, Dave the hunter moves up and down at 200 rpm for 3 seconds in celebration, then returns to 25 rpm.
if(duck1.pressing() or duck2.pressing() or duck3.pressing()){
dave.spin(forward);
dave.setVelocity(200,rpm);
wait(3,seconds);
dave.stop();
}
}
}
}
}
thanks for any feedback.