If you want to use sensor data in your application you probably want to map the values to a different range. Below a visualisation of the formula that you can use for that. Drag the sliders to change the virtual sensor input value and the maximum value of the sensor.
Visualisation removed, because Flash is now disabled on most devices. I might make a P5Js version, in the near future. Please comment if that would help you.
You can use this formula in every programming/scripting language of course. Below you can download a more complex example for Scratch4Arduino (S4A) that I use in my classes (it also includes a smoothing formula).