Yes Sir,
I do apologize for my incomprehensive programming skills. I am having trouble interrupting my motor with my limit switch. The program wants to complete the revolutions before stopping the motor. Programming micro controllers is a bit different than programming CNC machinery. So please, beat me up as much as it takes to get it through my thick skull.....
Thank You,
U_R
pinMode (swP1, INPUT); //limit switch left over travel motor #2
pinMode (swP2, INPUT); //limit switch right over travel motor #4
pinMode (mP, INPUT); //mag sensor (proximity) switch between motors 2 & 4
pinMode (enablePin, OUTPUT);
while (digitalRead (swP1)==LOW) //while limit switch 1 is OFF
{
motor2.stall(); //motor stop
delay(3000); //3 sex
motor2.go(FULL, -900, 10); // motor 2 rotate CCW 4-1/2 rev's
//THE MOTOR WANTS TO TURN FULL 4-1/2 REV'S BEFORE THE SWITCH STOPS IT
if (digitalRead (swP1)==HIGH) //if limit switch 1 is ON
{
}
else {
break;
}
}
}
void loop()
{
if (digitalRead(swP1) == HIGH) //if limit switch 1 is ON
if (digitalRead(swP1) == LOW) //if limit switch 1 is OFF
{
digitalWrite(enablePin, HIGH); // turn motor enable pin ON
motor2.go(FULL, 2000, 10); //THE MOTOR WANTS TO TURN FULL 10 REV'S BEFORE THE SWITCH STOPS IT
delay (5000); //5 sec's
}
if (digitalRead(swP1) == HIGH) // check if the input is HIGH
{
motor2.go(FULL, -2000, 10); // step motor 2 CCW 10 rev's
//THE MOTOR WANTS TO TURN FULL 10 REV'S BEFORE THE SWITCH STOPS IT
digitalWrite(enablePin, HIGH); // turn motor enable pin ON
motor2.stall(); //stop motor
delay(3000); //3 sex
}
}