If you don't update sensorValue and repeat the battery type detection code, I don't see how runWeight can change its value (this is just a suggestion, I might be wrong...)
Did I already tell you you should use CTRL-T and use empty lines in a sensible manner ? Trust me, it greatly helps writing understandable (and unbuggy) code.
![]()