As you may see by my sketch, this has three buttons, foward, stop reverse, when press forward run till count is reached then stops, same when press reverse, one question if moves forward and stops when count reached , how can i prevent from moving forward again, and the only direction allowed to move is reverse.

pinMode (13,OUTPUT); // new 17/08/11 use led on pcb to warn that calibration about to startpinMode(11,OUTPUT); // changes direction of motorpinMode(10,OUTPUT); // turns main relay power onpinMode(pulsePin, INPUT); digitalWrite(pulsePin, HIGH); // enable the 20K pull-up resistor to steer the input pin to a HIGH reading.Serial.begin(9600); // open serial port}

Hard to control the device as presented - you mention end stops in the code - they would help you make decisions about which buttons should be usable at any given point. Without them, all you can do is make assumptions that you know where the device is. Keep a state variable telling you whether you're moving in or out and use your counter to tell you how far you've gone. When you get a button press, use counter to tell you whether you're at either end of the travelling range - if you're all the way forward, ignore additional forward pressing, same for back. This'll need your calibration routine to be implemented in setup though so you know your starting point.

pinMode (13,OUTPUT); // new 17/08/11 use led on pcb to warn that calibration about to start pinMode(11,OUTPUT); // changes direction of motor pinMode(10,OUTPUT); // turns main relay power on pinMode(pulsePin, INPUT); digitalWrite(pulsePin, HIGH); // enable the 20K pull-up resistor to steer the input pin to a HIGH reading. Serial.begin(9600); // open serial port}

On second thought, just use counter as a position indicator. Set it in calibration, then increment it on forward ticks of the hall sensor, decrement it when going backwards. On that point, consider using an interrupt to ensure you don't miss anything from the hall.

1) using eeprom, i have not used before, it is the start of my calibration program, which the plan is to .a) mover motor in reverse till no pulse detected.b) reset couneterc) move forward till no pulses detected.d) store max pulses in memory.e) then return to start position (where counter was reset)