Magnet sensor sweep code

Note: Use '==' for comparison. You are setting 'pos to zero and never executing the 'if' because 0 is 'false'.

WARNING: C++ is not like Python. It doesn't care about indentation. It only cares about curly braces: { and }. From the indentation I think you might have meant:

else
{
  myservo.write(90,255,true)
  pos = 90;
}