Calculating Arduino Write Values

Linear Equation

We must scale our read values (0 to 1023) to suitable write values (0 to 255).

The math above shows how to derive an equation that allows us to calculate a suitable write value (0-255) from a read value (0-1023) on an arduino microcontroller.