Stepper Motor Interfacing with Particle Photon

Introduction

Stepper Motor

 

Stepper motor is a brushless DC motor that divides the full rotation angle of 360° into the number of equal steps.

The motor is rotated by applying a certain sequence of control signals. The speed of rotation can be changed by changing the rate at which the control signals are applied.

For more information about Stepper Motor and how to use it, refer the topic Stepper Motor in the sensors and modules section.

 

Interfacing Diagram

Interfacing Stepper Motor WithParticle Photon

Example

Rotating stepper motor in clockwise and counter clockwise directions alternately.

Here, we are using six wire unipolar stepper motor. Only four wires are required to control this stepper motor. The two center tap wires of the stepper motor are connected to the 5V supply.

The ULN2003 driver is used to drive a stepper motor.

Note: To find winding coils and their center tap leads, measure resistance in between the leads. From center leads we will get half the resistance value as compared to a resistance between winding ends.

 

Sketch For Stepper Motor

void setup() {
pinMode(D4, OUTPUT);
pinMode(D5, OUTPUT);
pinMode(D6, OUTPUT);
pinMode(D7, OUTPUT);
}

void loop() {
	/* Rotation in one direction */
for(inti = 0; i<12; i++)
  {
digitalWrite(D7, HIGH); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, HIGH); digitalWrite(D6, HIGH); digitalWrite(D5, LOW); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, HIGH); digitalWrite(D5, LOW); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, HIGH); digitalWrite(D5, HIGH); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, LOW); digitalWrite(D5, HIGH); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, LOW); digitalWrite(D5, HIGH); digitalWrite(D4, HIGH);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, HIGH);
delay(100);

digitalWrite(D7, HIGH); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, HIGH);
delay(100);
  }

digitalWrite(D7, HIGH); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, LOW);
delay(100);

	/* Rotation in opposite direction */
for(int j = 0; j<12; j++)
  {
digitalWrite(D7, LOW); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, HIGH);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, LOW); digitalWrite(D5, HIGH); digitalWrite(D4, HIGH);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, LOW); digitalWrite(D5, HIGH); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, HIGH); digitalWrite(D5, HIGH); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, LOW); digitalWrite(D6, HIGH); digitalWrite(D5, LOW); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, HIGH); digitalWrite(D6, HIGH); digitalWrite(D5, LOW); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, HIGH); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, LOW);
delay(100);

digitalWrite(D7, HIGH); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, HIGH);
delay(100);
  }

digitalWrite(D7, LOW); digitalWrite(D6, LOW); digitalWrite(D5, LOW); digitalWrite(D4, HIGH);
delay(100);
}

 

 


Components Used

Particle Photon
PHNTRAYH
1
ULN2003 Motor Driver
ULN2003A is a high-voltage, high-current Darlington transistor array.
1

Downloads

stepper Download
Ad