Stepper motor to compass location

Hi,

Fairly new to the Arduino and I'm not an especially good coder but having fun so far.

I have mapped a compass to a stepper motor using the easy driver and AccelStepper library.

My code works pretty well other than a slight problem I can't get my tiny mind around.

How do you stop the stepper from doing a full turn when it goes from 0 to 360 or 360 to 0? It works fine otherwise moving backwards and forwards. Advice much appreciated.

   if ((val > previous+6) || (val < previous-6)) {  // Check that a move of the pot is at least > or < than 6
    // map compass to number of steps
    newval = map(val, 360, 0, 0, 1600);
    stepper.moveTo(newval);
    previous = val;  // save current value into variable previous
	}
	    stepper.run();

shapingthings:
How do you stop the stepper from doing a full turn when it goes from 0 to 360 or 360 to 0? It works fine otherwise moving backwards and forwards. Advice much appreciated.

My wild guess is that you need to figure out how many steps the motor should take (and in what direction) rather than "where" it should go to.

...R