Sunday 8 July 2018

Arduino Tutorial - Stepper Motor Control with Potentiometer

0




This instructable is the written version of my "Arduino : How To Control a Stepper Motor with Potentiometer" YouTube video that I've uploaded recently. I strongly recommend you to check it out.
First, you should see the following Instructable:
This tutorial is all about tuning the speed of a stepper motor using a potentiometer. The idea is to up or down the speed of a stepper motor using with analog read. Theoretically analog input to a digital output, we're going to use this concept to control the speed of a running stepper motor.
Hardware Required :
- 10k Potentiometer

Circuit & Connections

The Stepper motor used here is a rusty old EPOCH (5 wires) stepper motor, which is a unipolar stepper.
Use the analog input with the help potentiometer to control the delay in-between each steps of the stepper motor. Shorter the delay in-between each steps - faster the stepper motor runs and vice-versa.

Programming



 
 // 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