Processing Forum
#include <Stepper.h>
const int spr = 20; // motor steps per revolution
const int pwm_cha = 3;
const int pwm_chb = 11;
const int dir_cha = 12;
const int dir_chb = 13;
const int brake_cha = 9;
const int brake_chb = 8;
Stepper stepper(spr, dir_cha, dir_chb);
void setup()
{
pinMode(pwm_cha, OUTPUT);
pinMode(pwm_chb, OUTPUT);
pinMode(brake_cha, OUTPUT);
pinMode(brake_chb, OUTPUT);
digitalWrite(pwm_cha, HIGH);
digitalWrite(pwm_chb, HIGH);
digitalWrite(brake_cha, LOW);
digitalWrite(brake_chb, LOW);
stepper.setSpeed(50);
}
void loop()
{
stepper.step(spr);
delay(2000);
}