I wanted to quickly demonstrate using a stepper motor from a floppy drive with the Arduino/Wiring platform as a follow up to the weekend’s workshop. By the time we got to the stepper parts I was a bit scattered. So here is an example that I set up yesterday.
I have a talking George Bush doll from several years ago that was ripped in half (by people watching my punk band (w.busholini.org)) so I went ahead and finished dismantling it. For Halloween I thought his head should turn around Linda Blair style.
I wired up a ULN2803 Darlington array and a floppy drive stepper motor from the workshop as shown in the diagram above .
I figured out which wire was the common wire by taking an ohmmeter to the wires on the stepper. Most of the combinations were about 150 except from one of the wires on the end that read 75 ohms. Checking the 75 against all of the other wires I was able to determine that one of the wires was the common one and marked it with a sharpie.
Then I ran up the arduino (v 17) example program for the stepper library. I modified it so that it just made steps in one direction. When I ran it the motion was really jittery so I checked to make sure that my wiring was good and then rather than rewiring the stepper physically I changed the line in the code from
Stepper stepper(STEPS, 9, 10, 11, 12);
to
Stepper stepper(STEPS, 9, 11, 10,12);
And Whah La! his head started spinning just like he was possessed by Dick Cheney! I wired the talk button to pin 8 and then added some random delays which gave me the following.
#include <Stepper.h> // change this to the number of steps on your motor #define STEPS 100 int relayPin=8; int ledPin=13; // create an instance of the stepper class, specifying // the number of steps of the motor and the pins it's // attached to Stepper stepper(STEPS, 9, 11, 10,12); // the previous reading from the analog input int previous = 0; void setup() { pinMode(relayPin,OUTPUT); pinMode(ledPin,OUTPUT); // set the speed of the motor to 30 RPMs stepper.setSpeed(100); } void loop() { // get the sensor value int val = analogRead(0); // move a number of steps equal to the change in the // sensor reading //stepper.step(val - previous); digitalWrite(ledPin, HIGH); stepper.step(random(5,90)); delay(random(60,2000)); digitalWrite(relayPin, HIGH); delay(20); digitalWrite(relayPin, LOW); digitalWrite(ledPin, LOW); stepper.step(-random(15,200)); delay(random(90,3000)); // remember the previous value of the sensor previous = val; }