Arduino code with microstep driver


#1

I have code attached below. My understanding is if i changed duty cycle
values, it will changes the motor speed, but in fact the speed of motor
doesn’t change by using my code. What did i miss or do wrong?
I tried to email technical suppor but they think it is arduino problem and
they can’t help. I used the prob to just see output from arduino and it gives
pretty nice signal when i change the duty cycle. Their sample code is way more
complicated for my application. Can anybody help me to spot the problem here?

Thanks in advance.

// Define pins
#define M_ENA 4
#define M_DIR 8
#define M_SPEED 11

void setup() {
// put your setup code here, to run once:
pinMode(M_ENA, OUTPUT);
pinMode(M_DIR, OUTPUT);
pinMode(M_SPEED, OUTPUT);
digitalWrite(M_ENA, HIGH);
digitalWrite(M_DIR, HIGH);
// Set prescaler to 32 at timer 2
TCCR2B = TCCR2B & B11111000 | B00000011;
analogWrite(M_SPEED, 50);
}

void loop() {
// put your main code here, to run repeatedly:
//Set the speed of motor

}


#2