Magnet sensor sweep code

is this sketch useless then? thx for your help.