Motor truncates decimal speed values

I currently have a motor connected to an arduino uno board with a potentiometer as an input and an LCD screen to display the input speed and the actual speed of the motor. The code also uses PID to correct errors in the motor speed. The motor needs to be able to run at decimal values, but as of right now the input speed value on the screen will read a decimal but the actual speed value will read the floor of that decimal. I have looked through the code and made sure everything that I thought needed to be float was a float value, but nothing has changed. Everything else in the code works fine. What exactly do I need to fix?

DCmotorTrial_wLCD_wEncoder_V03.2.ino (8.79 KB)

I recommend:
Hit CTRL-T to autoformat your code. I find it easier to read.
Print out some of your intermediary values to the serial monitor to see what is going on. Where are you losing the precision? Prints should help you find it.

OOPS! Never mind. :blush:

After you fix up the code formatting in the IDE (CTRL+T)
Please post your code in a block - which makes it accessible to all users.

String speed_reqString = String(speed_req);
String speed_actString = String(speed_act);
speed_reqString = speed_reqString.length();
speed_actString = speed_actString.length();

if (speed_actString > speed_reqString) {

The WTF light exploded.

The motor needs to be able to run at decimal values

What does this mean? You expect the motor to be able to spin at 14000.3 RPM instead of 14000?

Where, exactly, are you setting the speed of a motor? Specifically, what function are you using? What argument types does that function take?

That tree - the one over there - that is the one you should be barking up. This is the wrong tree.