what should be the code to rotate an steppermotor ANTI clockwise (reverse);
steppermotor works fine clockwise by sequencing HIGH LOW from output pin 8,9,10,11 to LN2003
what should be the code to rotate an steppermotor ANTI clockwise (reverse);
steppermotor works fine clockwise by sequencing HIGH LOW from output pin 8,9,10,11 to LN2003
Post the code that rotates clockwise, using code tags as described in "How to use this forum", and we can go from there.
void setup() {
// put your setup code here, to run once:
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}
void functieStep() //gehele cyclus afgesloeten met "uit"
{
digitalWrite(8,HIGH); //stappen volgens Rob's web
digitalWrite(9,LOW); //Full steps Alternate (more torque)
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
delay(1000);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
delay(100);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
delay(100);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(8,LOW); //zet motor uit
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
delay(100);
}
void loop() {
// put your main code here, to run repeatedly:
functieStep();
delay(10000);
}
Please edit your post to add code tags.
Have a look at this code taken from one of my projects. See how the sequence for powering the coils needs to be reversed for movement in the opposite direction.
void moveOneFullStep() {
static unsigned long prevStepMicros;
static char stepSequence = 0;
//~ if (firstStepOfSequence == true) {
//~ prevStepMicros = micros();
//~ firstStepOfSequence = false;
//~ }
if (micros() - prevStepMicros < tableStepIntervalMicros) {
return;
}
else {
stepCount ++;
//~ prevStepMicros += tableStepIntervalMicros;
prevStepMicros = micros();
}
if(tableDirection == 'F'){
stepSequence++;
}else{
stepSequence--;
}
if(stepSequence>3){
stepSequence=0;
}
if(stepSequence<0){
stepSequence=3;
}
switch(stepSequence){
case 0:
digitalWriteFast(stepperPin1, HIGH);
digitalWriteFast(stepperPin2, HIGH);
digitalWriteFast(stepperPin3, LOW);
digitalWriteFast(stepperPin4, LOW);
break;
case 1:
digitalWriteFast(stepperPin1, LOW);
digitalWriteFast(stepperPin2, HIGH);
digitalWriteFast(stepperPin3, HIGH);
digitalWriteFast(stepperPin4, LOW);
break;
case 2:
digitalWriteFast(stepperPin1, LOW);
digitalWriteFast(stepperPin2, LOW);
digitalWriteFast(stepperPin3, HIGH);
digitalWriteFast(stepperPin4, HIGH);
break;
case 3:
digitalWriteFast(stepperPin1, HIGH);
digitalWriteFast(stepperPin2, LOW);
digitalWriteFast(stepperPin3, LOW);
digitalWriteFast(stepperPin4, HIGH);
break;
}
}
And see the advantage of using the code button </> when posting code
...R
PS ... digitalWriteFast() does the same thing as digitalWrite()
thanks..
will study the code
and try it.
But please advice on how to post a code correctly in this forum
where to find and how to apply the </> button.
Regards
Anton Baaten
Antonio45:
what should be the code to rotate an steppermotor ANTI clockwise (reverse);steppermotor works fine clockwise by sequencing HIGH LOW from output pin 8,9,10,11 to LN2003
ULN2003 you mean.
The reverse sequence is 11,10,9,8,...
Which particular stepper is this?
Antonio45:
where to find and how to apply the </> button.
Click the button and insert the code [code]code goes here[/code]
Or enter the code, select it all and click the button
...R
thanks...
stepper 28BYJ-48