Questo è il codice che ho usato:
#include
int pinLed = 13;
#define motor1 5
#define motor2 6
#define motor3 7
#define motor4 8
#define STEPS 32
int Steps2Take;
Stepper small_stepper(STEPS, 5, 7, 6, 8);
const int IRPin = 3;
void setup() {
pinMode(pinLed,OUTPUT);
pinMode(motor1, OUTPUT);
pinMode(motor2, OUTPUT);
pinMode(motor3, OUTPUT);
pinMode(motor4, OUTPUT);
}
void loop() {
digitalWrite(pinLed,HIGH);
int IRState = digitalRead(IRPin);
if (IRState == LOW)
{
small_stepper.setSpeed(500);
Steps2Take = 256;
small_stepper.step(Steps2Take);
delay(2000);
}
}