Magnet sensor sweep code

Copy and paste the entire error message. The photo tells us nothing.

Also post the revised code, using code tags.