Hello, we have a conveyor belt powered by a motor on our bot. We want to press a button and make it run until we press the same button again. We cannot figure out how to do this. Here is what we currently have for our code:
Code:
//Conveyor Belt
boolean belt = false;
conveyorMotor.set(0);
if(belt == false){
if(stick.getRawButton(3)){
belt = true;
conveyorMotor.set(1);
}
else if(belt == true){
if(stick.getRawButton(3)){
belt = false;
conveyorMotor.set(0);
}
}
Currently this only turns on the belt while pressed and stops as soon as we let go. I feel like we're taking the totally wrong approach to this. Please help