team6749 / FRC-Coding-Documentation

1 stars 0 forks source link

code example change #3

Open asellingson28 opened 1 year ago

asellingson28 commented 1 year ago

within loop based programming.md, code could be changed to

    //check the blue limit switch
    if(!backwardSwitch.get()) {
        //This switch has been pressed (or unplugged)
        isForwardDirection = false;
    }

    //check the red limit switch
    if(!forwardSwitch.get()) {
        //this switch has been pressed (or unplugged)
        isForwardDirection = true;
    }

    //Secondly Move the duck motor based on the current forward direction
    if(isForwardDirection ) {
        //move the duck in the forward direction
        motor.set(ControlMode.PercentOutput, 0.3f);
    } else {
        //move the duck in the backwards direction
        motor.set(ControlMode.PercentOutput, -0.3f)
    }

== false could be replaced with ! for code concision and clarity :)