http://www.cumacini.altervista.org/Sistemi/Motore_passo_passo.pdf
https://www.itisfermi.edu.it/biblioteca/wp-content/uploads/2017/05/I-MOTORI-PASSO-PASSO.pdf





![]() ![]() |
Two Phase-On |
![]()
|
HALF STEP |

| Datasheet L298 |


int Step=0;
void setup()
{
DDRD = B00111110; // sets Arduino pins 1 to 7 as outputs, pin 0 as input
PORTD = B00000010;
}
byte Passi[]={B00101010, // 1010 +D -C +B -A
B00011010, // 0110 -D +C +B -A
B00010110, // 0101 -D +C -B +A
B00100110}; // 1001 +D -C -B +A
void StepOut(int thisStep)
{
PORTD = Passi[thisStep];
}
void DoStep(boolean fb)
{
if (fb)
{
Step++;
if (Step>3)
Step=0;
}
else
{
Step--;
if (Step<0)
Step=3;
}
StepOut(Step);
}
void loop()
{
DoStep(true);
delay(10);
}
#define motor_pin_1 2 #define motor_pin_2 3 #define motor_pin_3 4 #define motor_pin_4 5 int Step=0; int previous = 0; void setup() { DDRD = B00111110; // sets Arduino pins 1 to 7 as outputs, pin 0 as input PORTD = B00000010; } byte Passi[]={B00101010, // 1010 +D -C +B -A B00011010, // 0110 -D +C +B -A B00010110, // 0101 -D +C -B +A B00100110}; // 1001 +D -C -B +A void StepOut(int thisStep) { PORTD = Passi[thisStep]; } void DoStep(boolean fb) { if (fb) { Step++; if (Step>3) Step=0; } else { Step--; if (Step<0) Step=3; } StepOut(Step); } void Passi(int p) { int n; boolean f; f=p>=0; p=abs(p); for (n=1;n<=p;n++) { DoStep(f); delay(10); } } void loop() { int val = analogRead(0); // move a number of steps equal to the change in the // sensor reading Passi(val - previous); // remember the previous value of the sensor previous = val; }