Hi,
I'm working on a school project which requires me to turn a stepper motor to a certain degree every 12 hours or so. I'm using the Arduino Uno circuit board (I got from the arduino starter kit) and Arduino Uno Motor Shield R3 to turn my PM4222-09 stepper motor. I can't seem to get the codes right. I've been working on it for the past 4 days (on the codes only). But the outcome doesn't match my specifications. My stepper motor rotates a little bit before it delays for 3 seconds and repeat.(The "delay(300)" will be changed to a larger number to meet my specification when the codes are all correct).
Do help me out with this. I'm really new to this Arduino thing.
here is my code:
#include <Stepper.h>
Stepper myStepper = Stepper(100, 8, 9, 12, 13);
int delaylength = 80;
void setup() {
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
}
void loop(){
{
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(12, HIGH);
analogWrite(3, 250);
delay(delaylength);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(13, LOW);
analogWrite(11, 250);
delay(delaylength);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
digitalWrite(12, LOW);
analogWrite(3, 250);
delay(delaylength);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
digitalWrite(13, HIGH);
analogWrite(11, 250);
delay(delaylength);
}
delay(300);
}