So I am new to using sensors and I am learning to use the limit switch. I want the piston set to false when the limit switch is pressed, and the piston set true when a button on the controller is pressed. can anyone advise on what to do?
while (1) {
// This is the main execution loop for the user control program.
// Each time through the loop your program should update motor + servo
// values based on feedback from the joysticks.
// ........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
// ........................................................................
while(true){
Leftfront.spin(forward,Controller1.Axis3.position()+Controller1.Axis4.position()-Controller1.Axis1.position(), percent);
Rightfront.spin(forward,Controller1.Axis3.position()-Controller1.Axis4.position()+Controller1.Axis1.position(), percent);
Rightrear.spin(forward,Controller1.Axis3.position()+Controller1.Axis4.position()+Controller1.Axis1.position(), percent);
Leftrear.spin(forward,Controller1.Axis3.position()-Controller1.Axis4.position()-Controller1.Axis1.position(), percent);
if( LimitSwitchB.pressed(void )()){
piston.set( false );
}
else if(Controller1.ButtonY.pressed(void ()){
piston.set( false );
}
else if(Controller1.ButtonA.pressed(void ()){
piston.set( true );
}
else {
piston.set( true );
}
wait(20,msec);
i cant test the code because i have a problem and i dont understand the problem.
the first while loop has an error apparently
[clang] expected unqualified-id
void usercontrol(void) {
// User control code here, inside the loop
void
while (1) {
// This is the main execution loop for the user control program.
// Each time through the loop your program should update motor + servo
// values based on feedback from the joysticks.
// ........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
// ........................................................................
while(true){
Leftfront.spin(forward,Controller1.Axis3.position()+Controller1.Axis4.position()-Controller1.Axis1.position(), percent);
Rightfront.spin(forward,Controller1.Axis3.position()-Controller1.Axis4.position()+Controller1.Axis1.position(), percent);
Rightrear.spin(forward,Controller1.Axis3.position()+Controller1.Axis4.position()+Controller1.Axis1.position(), percent);
Leftrear.spin(forward,Controller1.Axis3.position()-Controller1.Axis4.position()-Controller1.Axis1.position(), percent);
if(Controller1.ButtonA.pressing()){
pistonStatus = true;
}
else if(LimitSwitchA){
pistonStatus = false; }
piston.set(pistonStatus);
wait(20, msec);
I may have screwed up. I am using pneumatics for expansion in this seasonās game and something is not working. I have narrowed the source of the problem to either the code or the solenoid. I tried to use the code you gave me earlier this year. Can you please check my code to see if the problem is with the code?
Honestly Iād just set the value of the piston right where you check if the button has been pressed. For example you can get rid of the bool āPistonStatusā and where it sets the Piston based on that at the end off the loop and replace the button code to look like so: