How do i make a limit switch stop then turn off so i can move foward

i am trying to make a limitswitch stop and then move forward enough to stop the limitswitch or stop and then use my move forward code

current code:

waitUntil(limitswitchE.pressing());
  LF_Drive.stop();
  RF_Drive.stop();
  LB_Drive.stop();
  RB_Drive.stop();

waitUntil(limitswitchH.pressing());
  LF_Drive.stop();
  RF_Drive.stop();
  LB_Drive.stop();
  RB_Drive.stop();

After reading through your post a few times, I am still confused what you are trying to do. Could you clarify?

Also, you never tell the motors to start moving, wich is a problem.

2 Likes

there is a three wire device called a limit switch I have got one of them on the back of my robot. when doing skills auton i use them to back into the wall for realignment.

i am new to programming this year but my coach insists on using a lot of sensors so i am very confused all the time

code again:

waitUntil(limitswitchE.pressing());
  LF_Drive.stop();
  RF_Drive.stop();
  LB_Drive.stop();
  RB_Drive.stop();

I think what @Robo_Chicken is saying is that with the code you have given us there is no spin function to actually start the motors.

1 Like

ok sorry i have that here

code:

void limiter(int powerx){
  LF_Drive.setVelocity(powerx,percent);
  RF_Drive.setVelocity(powerx,percent);
  LB_Drive.setVelocity(powerx,percent);
  RB_Drive.setVelocity(powerx,percent);

  LF_Drive.spin(forward);
  RF_Drive.spin(forward);
  LB_Drive.spin(reverse);
  RB_Drive.spin(reverse);

  waitUntil(limitswitchE.pressing());
  LF_Drive.stop();
  RF_Drive.stop();
  LB_Drive.stop();
  RB_Drive.stop();       
  

}