• HEADLINESoPEDIA

Stepper Motor Controller

This controller take signal from IR sensor and rotate the steper Motor by one revolution on 70 RPM. Whenever ir sensor is activated stepper motor rotate for one revolution.

You can use any sensor like fire sensor, water sensor in place of IR sensor.

Purchase Link of Items Used -

Stepper Motor- https://www.myinnovation.in/product-page/stepper-motor-nema17

Arduino Uno - https://www.myinnovation.in/product-page/arduino-uno

L293D Shield - https://www.myinnovation.in/product-page/stepper-motor-nema17

Ir sensor - https://www.myinnovation.in/product-page/ir-sensor-2-piece

12v 2A adapter - https://www.myinnovation.in/product-page/12v-2a-adapter


Arduino Code -

#include <AFMotor.h>

AF_Stepper motor1(200, 1); //1

void setup()

{

pinMode(A0, INPUT); //2

motor1.setSpeed(70); //3

}

void loop()

{

if(digitalRead(A0)==LOW) //4

{

motor1.step(200, FORWARD, DOUBLE); //5

}

}

Now Let us explain this code -

In this code

//1 -- 200 means stepper revolution for 1 complete cycle. Its 200 for NEMA17. as NEMA 17 has 1.8 degree step angle so revolution is 200.

and 1 means the signal pin is arduino 1 digital pin

//2 -- A0 i set for ir sensor.

// 3 -- 70 is motor speed. 70 simple means 70 RPM, if you want 100 then set 100

//4 -- here LOW means ir sensor in getting signal.

// 5 -- Here 200 means stepper will rotate for 1 full loop , forward direction of CW and Double means both coil of stepper excited.

How This Controller Works --