Using Stepper Motor from EPO Summer Camp
Motor driver L9110S H Bridge, a Stepper Motor, jumper cables are available at EPO Houston or online.
Stepper Motor Wiring:
From Motor Driver to Arduino
- A1B (white) to pin 8
- A1A (gray) to pin 9
- VCC to 5V
- GND to GND
- B1B (orange) to pin 10
- B1A (blue) to pin 11
From Stepper Motor to Motor Driver: Just had to match cables from stepper motor. However for some stepper motors the polarity pairs may be different.
Code
From video, but changed for stepper motor being used. (ie steps/rev are different)
Homework button code is not shown on purpose.
Hint: Add button and signal in and out wires to the Arduino.
#include <Stepper.h>
// The stepper motor used is 7.5 deg/steps => (1 rev/360 deg) *(360 deg/7.5 steps) = 48 steps/ rotation.
const int stepsPerRevolution = 48; // chg this to fit the #steps/rev for specific motor
Stepper motor(stepsPerRevolution, 8,9,10,11); // pins 8-11
int motorSpeed = 10; //24 in rpm = revolutions/minute
int delayTime = 3000;
void setup() {
Serial.begin(9600);
motor.setSpeed(motorSpeed);
}
void loop() {
motor.step(stepsPerRevolution); // fwd 1 revolution
delay(delayTime);
motor.step(-stepsPerRevolution); // reverse direction 1 rev
delay(delayTime);
}

No comments:
Post a Comment