Floppy drive stepper motor

Description

The stepper motor in this floppy drive is connected by 4 colored wires and is numbered 1 through 4 (1=black, 2=red, 3=green, 4=blue). First I used a multimeter to figure out which coils are connected to which of the wires. It took me a long time to get it to actually run. That was mostly because I did not know the speed and rpm of this motor. The wiring needed I figured out by trial-and-error. I got it to run with the following wiring setup: black > 3, green > 2, red > 1, blue > 3. As soon as the program starts running the stepper motor spins back and forth every few seconds.

From another floppy drive. I pulled off the connection wires too roughly and accidently took off the pins too

img img By a small code modification I was able to control the movement from the Serial Monitor, by entering integer values. This way I found out that my floppy drive motor makes 20 steps per revolution and it takes 175 steps to move the 'floppy disk reader head' from one side to the other. Also, the maximal revolutions per minute is about 1500 (at 1520, the motor simply does not rotate).

Parts

Code

#include <stepper.h>

const int stepsPerRevolution = 60;
const int pwmA = 3;
const int pwmB = 9;
const int dirA = 2;
const int dirB = 8;

Stepper myStepper(stepsPerRevolution, dirA, dirB);     

void setup() {
  pinMode(pwmA, OUTPUT);
  pinMode(pwmB, OUTPUT);
  digitalWrite(pwmA, HIGH);
  digitalWrite(pwmB, HIGH);
  myStepper.setSpeed(60);
}

void loop() {
  myStepper.step(stepsPerRevolution);
  delay(2000);
  myStepper.step(-stepsPerRevolution);
  delay(2000);
}