Hey there,
I did a course at Carnegie over the summer but my files didn’t transfer properly. So I am trying to get something done from memory and it is not working. I want my students to make the Vex EXP clawbot move using the remote control. We have the claw, arm and drive motors working fine. However, I want to play a game of tag so if their rear bumper gets pressed, I want the drive motors to stop until the student resets their code on the robot. I can’t seem to remember how to make this work. I have it written in notes but it doesn’t seem to be working. Here’s what we have, we are using C++:
// Include the VEX Library
#include "vex.h"
// Allows for easier use of the VEX Library
using namespace vex;
int main() {
clawMotor.setPosition(0, degrees);
armMotor.setPosition(0, degrees);
clawMotor.setStopping(hold);
armMotor.setStopping(hold);
clawMotor.setTimeout(5, seconds);
armMotor.setTimeout(5, seconds);
clawMotor.setVelocity(600, percent);
armMotor.setVelocity(30, percent);
rightMotor.setVelocity(30, percent);
leftMotor.setVelocity(30, percent);
while (1==1) {
if (Controller.ButtonR1.pressing()) {
clawMotor.spin(forward, 30, percent);
}
else if (Controller.ButtonR2.pressing()) {
clawMotor.spin(reverse, 30, percent);
}
else {
clawMotor.stop(hold);
}
if (Controller.ButtonL1.pressing()) {
armMotor.spin(forward, 30, percent);
}
else if (Controller.ButtonL2.pressing()) {
armMotor.spin(reverse, 30, percent);
}
else {
armMotor.stop(hold);
}
rightMotor.spin(forward, Controller.Axis2.position(percent)/2, percent);
leftMotor.spin(forward, Controller.Axis3.position(percent)/2, percent);
}
while (!rearBumper.pressing()) {
leftMotor.stop();
rightMotor.stop();
}
}