Tuesday 24 April 2018

Stepper Motor Control with Potentiometer

0



In this tutorial you will learn how to control a stepper motor using your  ULN2003 motor control chip

Stepper motors fall somewhere in between a regular DC motor and a servo motor. They have the advantage that they can be positioned accurately, moved forward or backwards one 'step' at a time, but they can also rotate continuously.


- Connection :

Note that the red lead of the Stepper motor is not connected to anything.

Use the colors of the leads to identify them, not the position from which they emerge from the motor.


- Hardware Required :

Arduino or Genuino Board
Stepper motor
ULN2003 driver
Breadboar
Jumper Wires
10k-potentiometer


Get Code :-

 
 // input pin for the potentiometer
int read_potentiometer = A0;

// input pin for the LED
int LED_pin = 13;

// input pin for the Step Motor 
int step_pin_1 = 8; 
int step_pin_2 = 9; 
int step_pin_3 = 10; 
int step_pin_4 = 11;

float delay_time;
int value_potentiometer = 0;

void setup()
{
Serial.begin(9600);
}

void loop() 

{
value_potentiometer = analogRead(read_potentiometer); 

   if (value_potentiometer >  0   ){
      delay_time=210-((value_potentiometer/5));  
    }
    else
    {
      delay_time=0;    // Minumum speed when it is 0
      }

Serial.println(value_potentiometer);

digitalWrite(LED_pin, HIGH);  
digitalWrite(8, HIGH); digitalWrite(step_pin_2, HIGH); digitalWrite(step_pin_3, LOW); digitalWrite(step_pin_4, LOW);   
delay(delay_time);

digitalWrite(LED_pin, LOW); 
digitalWrite(step_pin_1, LOW); digitalWrite(step_pin_2, HIGH); digitalWrite(step_pin_3, HIGH); digitalWrite(step_pin_4, LOW);  
delay(delay_time);

digitalWrite(LED_pin, HIGH); 
digitalWrite(step_pin_1, LOW); digitalWrite(step_pin_2, LOW); digitalWrite(step_pin_3, HIGH); digitalWrite(step_pin_4, HIGH);  
delay(delay_time);

digitalWrite(LED_pin, LOW);   
digitalWrite(step_pin_1, HIGH); digitalWrite(step_pin_2, LOW); digitalWrite(step_pin_3, LOW); digitalWrite(step_pin_4, HIGH);  
delay(delay_time); 
}
Author Image

About Tech Hunt
Soratemplates is a blogger resources site is a provider of high quality blogger template with premium looking layout and robust design

No comments:

Post a Comment