I have found code for running a step motor ( https://os.mbed.com/users/XtaticO/code/sMotor/file/4b3b9e047ce3/sMotor.cpp/ ), however I am not sure if it is correct:
void sMotor:anticlockwise() { //rotate the motor 1 step anticlockwise
for(int i = 0; i < 8; i++) {
switch (i) { // activate the ports A0, A2, A3, A3 in a binary sequence for steps
case 0: {
_A0=0;
_A1=0;
_A2=0;
_A3=1;
}
break;
case 1: {
_A0=0;
_A1=0;
_A2=1;
_A3=1;
}
break;
case 2: {
_A0=0;
_A1=0;
_A2=1;
_A3=0;
}
break;
case 3: {
_A0=0;
_A1=1;
_A2=1;
_A3=0;
}
break;
case 4: {
_A0=0;
_A1=1;
_A2=0;
_A3=0;
}
break;
case 5: {
_A0=1;
_A1=1;
_A2=0;
_A3=0;
}
break;
case 6: {
_A0=1;
_A1=0;
_A2=0;
_A3=0;
}
break;
case 7: {
_A0=1;
_A1=0;
_A2=0;
_A3=1;
}
break;
}
wait_us(motorSpeed); // wait time defines the speed
}
}
The rest of the class works with this implementation, am I right in assuming that calling this function will move the motor 8 steps, and not one, or is there something I do not understand.
not sure if it is correct
.... correct for what? .... it would totally not work on my arduino \$\endgroup\$