nxtrobotc

Robot-C Slow Down Motor (Tetrix)


So I want to slow down a motor on a Tetrix Robot:

Here's my code:

//Makes the main frame of arm move up and down  

    motor[motorE] = joystick.joy1_y2 ;

How can I make the values given by joystick.joy1_y2slower?


Solution

  • I'm the programmer on an FTC Team and we use RobotC, like it appears you are using. If you are, you can just divide the joystick.joy1_y2 by some other value for instance:

    motor[motorE] = (joystick.joy1_y2/2);
    

    And you could make that adjustable by using something like:

    int motorDivide = 1;
    
    task motorTask;
    
    task main(){
    
        StartTask(motorTask);
    
        while(true){
           getJoystickSettings(joystick);
        }
    
    }
    
    task motorTask(){
        while(true){
    
            if (joy1Btn(1) == 1){
                motorDivide+=1;
                if (motorDivide >= 3){
                    motorDivide = 1;
                }
                wait1Msec(100);
            }
    
            motor[motorE] = (joystick.joy1_y2/motorDivide);
        }
    }