Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 108 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

stepper Stepper motor is not working according to code

#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 480  //2048  
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
int Steps2Take;
int dirpin=8;
int steppin=9;
int buttonApin=2;
int buttonBpin=3;

void setup()
  {
    pinMode(dirpin,OUTPUT);
    pinMode(steppin,OUTPUT);
    pinMode(buttonApin,INPUT);
    pinMode(buttonBpin,INPUT);
}

void loop()
  {
    int valA=digitalRead(buttonApin);
    int valB=digitalRead(buttonBpin);
    if(valA==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(40000);
        delay(1000);
    }
    if(valB==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
 
        small_stepper.step(-40000);
        delay(1000);
    }
    if((valA==LOW)&&(valB==LOW))
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(0); 
    }
}

Here I have written this code to rotate stepper motor. When the input on digital pin 2 becomebecomes high, then the motor should rotate clockwise. When the digital pin 3 becomebecomes high, it should rotate in a different direction. When the input on both pins the input is low, the motor should not move.

But with this code the motor is moving continuously even if you apply high input atto digital pins.

Please suggest how to fix this problem. For input signal I am taking signal from relays: if relay is in on condition, it should give a high signal and vice versa.

stepper motor is not working according to code

#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 480  //2048  
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
int Steps2Take;
int dirpin=8;
int steppin=9;
int buttonApin=2;
int buttonBpin=3;

void setup()
 {
    pinMode(dirpin,OUTPUT);
    pinMode(steppin,OUTPUT);
    pinMode(buttonApin,INPUT);
    pinMode(buttonBpin,INPUT);
}

void loop()
 {
    int valA=digitalRead(buttonApin);
    int valB=digitalRead(buttonBpin);
    if(valA==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(40000);
        delay(1000);
    }
    if(valB==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
 
        small_stepper.step(-40000);
        delay(1000);
    }
    if((valA==LOW)&&(valB==LOW))
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(0); 
    }
}

Here I have written this code to rotate stepper motor. When the input on digital pin 2 become high then motor should rotate clockwise. When the digital pin 3 become high it should rotate in different direction. When on both pins the input is low the motor should not move.

But with this code the motor is moving continuously even if you apply high input at digital pins.

Please suggest how to fix this problem. For input signal I am taking signal from relays: if relay is in on condition it should give high signal and vice versa.

Stepper motor is not working according to code

#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 480  //2048  
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
int Steps2Take;
int dirpin=8;
int steppin=9;
int buttonApin=2;
int buttonBpin=3;

void setup() {
  pinMode(dirpin,OUTPUT);
  pinMode(steppin,OUTPUT);
  pinMode(buttonApin,INPUT);
  pinMode(buttonBpin,INPUT);
}

void loop() {
  int valA=digitalRead(buttonApin);
  int valB=digitalRead(buttonBpin);
  if(valA==HIGH) {
    digitalWrite(steppin,HIGH);
    digitalWrite(dirpin,LOW);
    small_stepper.step(40000);
    delay(1000);
  }
  if(valB==HIGH) {
    digitalWrite(steppin,HIGH);
    digitalWrite(dirpin,LOW);
    small_stepper.step(-40000);
    delay(1000);
  }
  if((valA==LOW)&&(valB==LOW)) {
    digitalWrite(steppin,HIGH);
    digitalWrite(dirpin,LOW);
    small_stepper.step(0);
  }
}

Here I have written this code to rotate stepper motor. When the input on digital pin 2 becomes high, then the motor should rotate clockwise. When the digital pin 3 becomes high, it should rotate in a different direction. When the input on both pins is low, the motor should not move.

But with this code the motor is moving continuously even if you apply high input to digital pins.

Please suggest how to fix this problem. For input signal I am taking signal from relays: if relay is in on condition, it should give a high signal and vice versa.

Bumped by Community user
Bumped by Community user
Bumped by Community user
#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 480  //2048  
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
int  Steps2Take;
int dirpin=8;
int steppin=9;
int buttonApin=2;
int buttonBpin=3; 

void setup()
{
    pinMode(dirpin,OUTPUT);
    pinMode(steppin,OUTPUT);
    pinMode(buttonApin,INPUT);
    pinMode(buttonBpin,INPUT);
 
} 

void loop()
{
    int valA=digitalRead(buttonApin);
    int valB=digitalRead(buttonBpin);
    if(valA==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(40000);
        delay(1000);
    }
    if(valB==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);

        small_stepper.step(-40000);
        delay(1000);
    }
    if((valA==LOW)&&(valB==LOW))
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(0); 
    } 
}

Here iI have written this code to rotate stepper motor when. When the input on digital pin 2 become high then motor should rotate clockwise and when. When the digital pin 3 become high it should rotate in different direction  .and when When on both pins the input is low the motor should not move.but

But with this code the motor is moving continuously even if uyou apply high input at digital pins.plz

Please suggest how to fix this problem. forFor input signal iI am taking signal from relays: if relay is in on condition it should give high signal and vice versa.

#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 480  //2048  
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
int  Steps2Take;
int dirpin=8;
int steppin=9;
int buttonApin=2;
int buttonBpin=3;
void setup()
{
pinMode(dirpin,OUTPUT);
pinMode(steppin,OUTPUT);
pinMode(buttonApin,INPUT);
pinMode(buttonBpin,INPUT);
 
}
void loop()
{
int valA=digitalRead(buttonApin);
int valB=digitalRead(buttonBpin);
if(valA==HIGH)
{
digitalWrite(steppin,HIGH);
digitalWrite(dirpin,LOW);
small_stepper.step(40000);
delay(1000);
}
if(valB==HIGH)
{
digitalWrite(steppin,HIGH);
digitalWrite(dirpin,LOW);

small_stepper.step(-40000);
delay(1000);
}
if((valA==LOW)&&(valB==LOW))
{   digitalWrite(steppin,HIGH);
digitalWrite(dirpin,LOW);
small_stepper.step(0); 
}}

Here i have written this code to rotate stepper motor when the input on digital pin 2 become high then motor should rotate clockwise and when the digital pin 3 become high it should rotate in different direction  .and when on both pins the input is low motor should not move.but with this code the motor is moving continuously even if u apply high input at digital pins.plz suggest how to fix this problem. for input signal i am taking signal from relays if relay is in on condition it should give high signal and vice versa.

#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 480  //2048  
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
int Steps2Take;
int dirpin=8;
int steppin=9;
int buttonApin=2;
int buttonBpin=3; 

void setup()
{
    pinMode(dirpin,OUTPUT);
    pinMode(steppin,OUTPUT);
    pinMode(buttonApin,INPUT);
    pinMode(buttonBpin,INPUT);
} 

void loop()
{
    int valA=digitalRead(buttonApin);
    int valB=digitalRead(buttonBpin);
    if(valA==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(40000);
        delay(1000);
    }
    if(valB==HIGH)
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);

        small_stepper.step(-40000);
        delay(1000);
    }
    if((valA==LOW)&&(valB==LOW))
    {
        digitalWrite(steppin,HIGH);
        digitalWrite(dirpin,LOW);
        small_stepper.step(0); 
    } 
}

Here I have written this code to rotate stepper motor. When the input on digital pin 2 become high then motor should rotate clockwise. When the digital pin 3 become high it should rotate in different direction. When on both pins the input is low the motor should not move.

But with this code the motor is moving continuously even if you apply high input at digital pins.

Please suggest how to fix this problem. For input signal I am taking signal from relays: if relay is in on condition it should give high signal and vice versa.

Source Link
shweta S
  • 21
  • 1
  • 5

stepper motor is not working according to code

#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32   
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 480  //2048  
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
int  Steps2Take;
int dirpin=8;
int steppin=9;
int buttonApin=2;
int buttonBpin=3;
void setup()
{
pinMode(dirpin,OUTPUT);
pinMode(steppin,OUTPUT);
pinMode(buttonApin,INPUT);
pinMode(buttonBpin,INPUT);

}
void loop()
{
int valA=digitalRead(buttonApin);
int valB=digitalRead(buttonBpin);
if(valA==HIGH)
{
digitalWrite(steppin,HIGH);
digitalWrite(dirpin,LOW);
small_stepper.step(40000);
delay(1000);
}
if(valB==HIGH)
{
digitalWrite(steppin,HIGH);
digitalWrite(dirpin,LOW);

small_stepper.step(-40000);
delay(1000);
}
if((valA==LOW)&&(valB==LOW))
{   digitalWrite(steppin,HIGH);
digitalWrite(dirpin,LOW);
small_stepper.step(0); 
}}

Here i have written this code to rotate stepper motor when the input on digital pin 2 become high then motor should rotate clockwise and when the digital pin 3 become high it should rotate in different direction .and when on both pins the input is low motor should not move.but with this code the motor is moving continuously even if u apply high input at digital pins.plz suggest how to fix this problem. for input signal i am taking signal from relays if relay is in on condition it should give high signal and vice versa.