-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
I wanted to set the start position of the stepper and attached an opto sensor to allow the stepper motor to be moved until a hole in a rotated cardboard disc, caused the opto to read Low.
This all went to plan until I realised that the library initialised its position from the first call to CheapStepper stepper (8,9,10,11) .
I realised I needed a new library call (stepReset) to set stepN = 0 and hence establish a new base position.
void CheapStepper::stepReset(){
stepN = 0;
}
This works well.
My centering code;
byte a = digitalRead(12); // opto sensor on pin 12
if(a==1){
Serial.println("Centering..");
while(a == 1){
stepper.move (moveClockwise, 1);
a = digitalRead(12);
}
stepper.stepReset(); // reset position count
Serial.println("Centred"); Serial.flush();
stepper.newMove(moveClockwise, 0); // fixes a restart issue
}
Others may find this useful,
David
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels