Obviously I'm missing something! Using an ELEGOO UNO, Makeblock 42BYG Stepper Motor, Makeblock Megapi Stepper Motor Driver v1, 12v battery.
Have tried to get a cell phone picture of connections but resolution keeps it unreadable. On the Driver board I am not using the Mode pins (0, 1, 2) at all. Promise the other pins are in agreement w/ this:
driver board DIR at UNO Pin 3
driver board SEP at UNO Pin 4
driver board SLP at UNO Pin 5
driver board RST at UNO Pin 6
driver board EN at UNO Pin 7
The code below (a few very simple lines beyond the example posted by UKHeliBob on Nov. 6th). This code makes the motor vibrate, nothing else. What am I missing? Have double checked pins and connections. I'm assuming there is some initialization or "start to move" code I need.
HELP! and thanks
// stepper motor, Uses 12V DC power. uses delay() to manage timing. Implemented on ELEGOO UNO R3.
char pgmname[] = "step-only1-for-forum";
int n, passcount;
int dir;
int stepsperrevolution = 200;
int wait;
byte directionPin = 3;
byte stepPin = 4;
byte sleepPin = 5;
byte resetPin = 6;
byte enablePin = 7;
byte ledPin = 12;
unsigned long pulseWidthMicros = 500; // microseconds
unsigned long millisbetweenSteps = 250; // milliseconds - or try 1000 for slower steps
void pass(){
Serial.println("After pass = " + String(passcount) + ". Enter 1 line comment for this pass or a dot, then press ENTER:");
while (!Serial.available()){ ;}
delay(50);
while(Serial.available())
{
Serial.println(String(Serial.readString()));
}
}
void motogo(){
digitalWrite(ledPin,HIGH);
for(n = 0; n < stepsperrevolution; n++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(pulseWidthMicros);
digitalWrite(stepPin, LOW);
delayMicroseconds(pulseWidthMicros);
}
digitalWrite(ledPin, LOW);
passcount++;
return;
}
void setup() {
Serial.begin(9600);
Serial.println(pgmname);
pinMode(ledPin, OUTPUT);
pinMode(directionPin, OUTPUT);
pinMode(stepPin, OUTPUT);
pinMode(sleepPin, OUTPUT);
pinMode(resetPin, OUTPUT);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
digitalWrite(resetPin, HIGH);
digitalWrite(sleepPin, HIGH);
digitalWrite(directionPin, HIGH);
passcount = 0;
}
void loop() {
motogo(); // uses values to turn stepper
pass(); //hold for user input to continue
}