/*
Arduino | general
bastianuvuvu - UNDIKSHA — 12/7/24 at 11:18 PM
you mean the A- A+ , B+ B-?
*/
// Define pin connections & motor's steps per revolution
const int DIR_PIN = 2;
const int STEP_PIN = 3;
const int STEPS_PER_REV = 200;
void setup() {
// Declare pins as Outputs
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
}
void loop() {
// Set motor direction clockwise
digitalWrite(DIR_PIN, HIGH);
// Spin motor slowly
for (int x = 0; x < STEPS_PER_REV; x++) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(2000);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(2000);
}
delay(1000); // Wait a second
// Set motor direction counterclockwise
digitalWrite(DIR_PIN, LOW);
// Spin motor quickly
for (int x = 0; x < STEPS_PER_REV; x++) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(1000);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(1000);
}
delay(1000); // Wait a second
}