Hi can any one help I am trying to make a distance sensor using a hall effect sensor. What I want to end up with is a sensor that can detect a magnetic field and slow a motor using pwm as it approaches the field. The problem is the sensor only gives an increasing posative number as it approaches or leaves the field. I have tried breaking the number into two words bo and b1 then using bo as the control of the pwm but the sensor is then not sensitive enough. I have also tried if statements ( if the reading is this then pwm output fast or slow) but this doesn't work well either. What I'm thinking is to change the posative going number into a direct opposite then feed that Into the pwm control can anyone help with the maths?