Paul,
I wish I had 1/16 of the knowledge you obtain. How about this for test purposes?
(edits)
- I am only really using A1 & A2 for motors 2 & 4
- I changed 300000 to 3000
- i changed rotation from 90000 900
I don't mind criticism. Please read on, I really want to know what I am doing wrong.
My father once said told me. "If you don't learn something new every day, then you are wasting your time"
Thank You,
U_R
As well sir, could you elaborate a little to what you mean here
What's the purpose of reading the switch state?
int i = 900;
int j = 0;
void setup() {
// assign the pin connections for my motors
motor2.set_microstep_select_pins(A1);
motor4.set_microstep_select_pins(A2);
// set the mag pin and the switch pins as inputs:
pinMode (switchPin1, INPUT);
pinMode (switchPin2, INPUT);
pinMode (magPin, INPUT);
pinMode (enablePin, OUTPUT);
// create at start up command procedure to run once
// i was thinking I could run this from void set up to run once
for (int i = 900; i > 0; i--); // Amount of maximum space i can travel changed from 90000
motor2.go(FULL, -i, 10); // Rotate motor 2 CCW from anywhere power is lost
if (digitalRead (switchPin1) == LOW) { // When I trigger switch left it should read low removed semicolon
delay (3000); // Delay for 3 sec
} // Here it will not exit void setup into void loop
}
void loop() {
//at this point switch left will read low and mag pin will be high
//so it should skip the while statement and loop back to it when the statement is true at the end of code
//also I am testing only motor 2 in this sketch for simplicity at this time
for (int x = 0; x < 20; x++); //repeat 20 times
while (digitalRead (magPin) == LOW){ //read prox switch low when interrupted
motor2.stall (); //stop motor
delay (3000); //delay 5 min
{
for (int j = 0; j < 900; j--); //amount of maximum space i can travel
}
for (int x = 20; x > 0; x--); //repeat 20 times
if (digitalRead (magPin) == HIGH){ //prox switch pin is high until triggered
motor2.go(FULL, -j, 10); //rotate motor CCW until prox switch is triggered
}
else {
sensorValue = digitalRead (magPin); //read current value of prox switch should be low
delay (3000); //delay for 3 sec changed from 5 min
}
}
}