State change once reach sensor

I am having a bit of trouble trying to find information on the code I need to adapt and was hoping someone might be able to help! What I’m wanting to do is control a motor through a hall effect sensor. So I want to have two magnets, one facing north and one south. When the hall effect sensor is low it will be at south and high when it is at north. But in the code, I am trying to figure out how I put in that when the hall effect sensor is low, turn the motor on until the hall effect sensor is high.
This is what I have so far:
`// These values may be different for your servo
const SERVO1_MIN = 0.00;
const SERVO1_MAX = 0.1;

// may not need this as servo is just turning in different directions

hardware.pin7.servo1.configure(PWN_OUT,0.002,0.0)
//period of motor turning at .002 seconds this means how long the motor is on for
// as it is at 0% high, could mean that if turn it to a negative it turns in reverse
hardware.pin6.halleffect.configure(DIGITAL_IN)
//configure hall effect1 as in

servo1 <- hardware.pin7;

halleffect1 <- hardware.pin5

function Sweep(value) {
hallState = digitalRead(halleffect1)
//if sleep function is called and the magnet isn’t aligned at low (south)
if (halleffect1 == LOW) {
// if the hall effect is not high then turn motor on
// low is when it is at the south pole of the magnet?

hardware.pin7.servo1.write(PWN_OUT,0.025,1);
//set servo to move up - in required direction for .0025 seconds
// set to one so it is high in the positive direction
until (hardware.pin6.halleffect == HIGH)

until halleffect1 == HIGH
hardware.pin7.servo1.write(PWN_OUT,0.0,0.0)
//turn motor off once get to hall effect
}
else {
hardware.pin7.servo1.write(PWN_OUT,0.0,0.0)
//motor is off if it is already at south of hall effect

// do it again in half a second:
imp.wakeup(1.0, Sweep);
} Sweep()`

This is the part of the code that I’m trying to figure out:

`if (halleffect1 == LOW) {
// if the hall effect is not high then turn motor on
// low is when it is at the south pole of the magnet?

hardware.pin7.servo1.write(PWN_OUT,0.025,1);
//set servo to move up - in required direction for .0025 seconds
// set to one so it is high in the positive direction
until (hardware.pin6.halleffect == HIGH)

until halleffect1 == HIGH
hardware.pin7.servo1.write(PWN_OUT,0.0,0.0)
//turn motor off once get to hall effect`