Steppermotor left right and stop

'single line'

multiple 
lines

const int richtingPin = 8; //We geven pin 8 een naam
const int stappenPin = 7; //We geven pin 7 een naam
const int knoplinksdraaien = A0; //Geef pin A0 nu de naam knoplinksdraaien
const int knoprechtsdraaien = A1; //Geef pin A0 nu de naam knoprechtsdraaien
const int stopknop = A2;

void setup(){ //Start setup wordt 1 keer gelezen
pinMode (richtingPin,OUTPUT); //Je stelt de pin in als output
pinMode (stappenPin, OUTPUT); //Je stelt de pin in als output
pinMode (knoplinksdraaien, INPUT_PULLUP); //Stel pin links in als input
pinMode (knoprechtsdraaien, INPUT_PULLUP); //Stel pin rechts in als input
pinMode (stopknop, INPUT_PULLUP);
Serial.begin(9600); //seriele verzending wordt aangemaakt
//Wacht 50 milliseconden
steprechts(false, 32000); //Einde setup loop
}

void loop(){ //Start loop (wordt eindeloos herhaald)

steplinks(true, 32000); //We springen naar de subroutine en nemen de draairichting en aantal stappen mee (48x7,5=360 graden)
steprechts(false, 32000); //We springen naar de subroutine en nemen de draairichting en aantal stappen mee (48x7,5=360 graden)
} //Einde van de if lus
//Einde hoofd routine
void steplinks(boolean richting, int aantalstappen){ //Start van de subroutine, signaal van de driver naar de richting
digitalWrite(richtingPin, richting); //Richting naar de pin schrijven
delay(50); //Wacht 50 milliseconden
for (int i=0;i<aantalstappen;i++){ //16 bits geheugen plek reserveren, voer for lus uit zolang i kleiner is dan het aantal stappen.
Serial.println(i);

if (digitalRead(stopknop)==LOW){ //Als de pin knoprechtsdraaien als LOW word gelezen, ga verder
Serial.println("stop knop");
break;
steprechts(false, 32000);
}

digitalWrite(stappenPin, HIGH); //Zet pin op 5V
delayMicroseconds(1200); //Wacht 1200 ms
digitalWrite(stappenPin, LOW); //Zet pin op 0V
delayMicroseconds(1200); //Wacht 1200 ms
} //Einde van de subroutine
}

void steprechts(boolean richting, int aantalstappen){ //Start van de subroutine, signaal van de driver naar de richting
digitalWrite(richtingPin, richting); //Richting naar de pin schrijven
delay(50); //Wacht 50 milliseconden
for(int i=0;i<aantalstappen;i++){ //16 bits geheugen plek reserveren, voer for lus uit zolang i kleiner is dan het aantal stappen.
Serial.println(i);

if (digitalRead(stopknop)==LOW){ //Als de pin knoprechtsdraaien als LOW word gelezen, ga verder
Serial.println("stop knop");
break;
steplinks(false, 32000);
}

digitalWrite(stappenPin, HIGH); //Zet pin op 5V
delayMicroseconds(1200); //Wacht 1200 ms
digitalWrite(stappenPin, LOW); //Zet pin op 0V
delayMicroseconds(1200); //Wacht 1200 ms
} //Einde van de subroutine
} //Einde van het

Welcome to the forum.

Did you miss the message that asked you to read the guidelines before posting or just ignore it?

My crystal ball is out for an oil change so you will have to tell us what is the problem with the improperly posted code.

Read the forum guidelines to see how to properly post code and some good information on making a good post.

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please go back and fix your original post

You could have saved a lot of us a lot of time including yourself if you took time to read the guidelines. The help and information if free, following the guidelines makes it much more inclined and easier for us to help. Doing it your way will probably add days before you get an viable answer. Most of us know stepper motors can go in either direction or stop. I assume there is a hidden question somewhere in this but I do not have a clue as to what you want. Fix your post and maybe you will get the help you need, be sure to include your question as most of us don't play guessing games. While you are at it post an annotated schematic of your circuit with links to technical information on each of the hardware devices.

One stepper function is blocking the other. When I put "psuedo" functions in place of your stepper functions, you can see how they are both called (R and L). However, when the original "rechts" function is called, it is blocking any calls to the "links" function. The "stop" button works in both R and L functions. Vista...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.