PROS Coding Help & LCD

Hey guys, I’ve just been having some trouble getting my claw code to work properly and I am using C with V5. I am using the X and B buttons to open and close the claw motor which is on port 7, but the code yields no result on the bot. I have been trying to use the LCD on the brain to print some values and debug my code but the print statements aren’t working either. I have tried to use different wires or change the port but nothing happens. If you guys could tell me what I am doing wrong with the print statements and the motor move functions that would be awesome.

//claw
if(controller_get_digital(E_CONTROLLER_MASTER, E_CONTROLLER_DIGITAL_X)) {
int k = 50 ;
motor_move_voltage(7, 50);

  lcd_print(0, "CLAW VELOCITY: ", k);
}
else if(controller_get_digital(E_CONTROLLER_MASTER, E_CONTROLLER_DIGITAL_B)) {
  int x = 0;
  motor_move_voltage(7, 0);

  lcd_print(0, "CLAW VELOCITY: ", x);
}

Check the range of voltage it’s +/- 12000.
https://pros.cs.purdue.edu/v5/api/c/motors.html?highlight=motor_move_voltage#motor-move-voltage

1 Like

Got it that makes sense. But when a joystick is matched proportionally with the motor voltage, the the max outputs are achieved with joystick values of ± 127. How does that make sense if the motor voltage range is 12000 millivolts?

You can scale it. (JoyVal/127)*12000. Or use okapilib which handles a lot of this for you.

I haven’t used full pros API so there may be more direct ways.

1 Like

Use motor_move(). That uses a scale of ±127.
However, rpm is correct, if you use move_voltage you need to scale it by a constant.

3 Likes

For your print statement to work, you need to specify the value you are passing in.
In this case, x is an int so the print statement should look like this:

lcd_print(0, "CLAW VELOCITY: %i", x);

If x is a float, then you use "%f", if it is a string, "%s" and so on.

2 Likes