delay(degrees * 9.2 * (time_multiplier_move_right / 100));
a bit basic but:
i have this code here, when time_multiplier_move_right is not 100 then the delay does not run at all
i need to use a variable here since i have a remote which controls the value of time_multiplier_move_right and then stores it to eeprom
Try this:
delay(degrees * 9.2 * (time_multiplier_move_right / 100.0));
oh, that works, thanks
Do you care why?
Yes, but I tried googling what happened and apparently dividing an int by an int removes the decimal point. Thanks
Actually, in C/C++, dividing an int by an int, which is called "integer division" makes a result which is also an int. There never was any decimal point to remove.
Changing 100 to 100.0 changed the code so that it was dividing an int by a float (or double). In that situation, the int gets converted to a float and float division is used, which has a decimal point.
Or this:
delay(degrees * 92 * time_multiplier_move_right / 1000);
If rounding is important:
delay((degrees * 92 * time_multiplier_move_right + 500) / 1000);
And: you might run into integer overflow.
In that case: 92ul should do the trick.