Unipolar Stepper Motor controlled by potentiometer
Identify a stepper motor by rotating its center shaft. If you can feel tiny pulses or clicks, you have a stepper motor. Now count the number of wire leads connected to your motor. If the motor has 5 or 6 wire leads, it is a unipolar stepper motor. If it has four wire leads it is a bipolar stepper motor. The circuit below is for a unipolar stepper motor.
A stepper motor is the best motor to use for timing, or for a project involving gears. Each rotation is a controlled number of clicks therefore it is known for its accuracy. Use your potentiometer to adjust the speed of your stepper motor. Be sure to play around with the math in the program to get the best range, from slow to fast rotations of your motor, through your potentiometer.
Note: You will need to play around with the wire leads coming out of the stepper motor. Determine which is positive and which order the other four leads should be placed in the circuit. In the stepper motor used for the in-class tutorial the order was: white, green, red, black going into the darlington array integrated circuit (IC chip). Not all motors will have the same configuration! :(
// program a unipolar stepper motor to be controlled by a potentiometer
// a stepper motor is the best choice for controlling motor speed with the greatest accuracy
// its accuracy is based on the number of ticks per rotation, like a watch motor
int motorPin1 = 2;
int motorPin2 = 3;
int motorPin3 = 4;
int motorPin4 = 5;
int analogPin = 1;
int delayTime = 50;
int val; // reads the input pin; val is a number coming in thats btwn 0 and 1023
void setup() {
Serial.begin(9600);
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
}
void loop() {
int val = analogRead(analogPin); // read the input pin; val is a number coming in thats btwn 0 and 1023
Serial.println(val); // makes sure that potentiometer is working
delayTime = (val /3) + 15 ; // factors in time before the motor makes another step in speed
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(delayTime);
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(delayTime);
}
Comments (0)
You don't have permission to comment on this page.