Go Down

Topic: probleme with stepper (Read 233 times) previous topic - next topic

mhamed213

hey peopel i have a problem with stepper motor i cant stop it with a code

vinceherman

Hi mhamed213 welcome to the forum.
Tell us which motor you have.
Post your code.  Use code tags.

As a new forum member, you might not have read through the forum guidelines.
It will help you if you do.  They are here How to use this forum - please read

mhamed213

the stepper (motor 28by-48)


#include <CheapStepper.h>

// next, declare the stepper
// and connect pins 8,9,10,11 to IN1,IN2,IN3,IN4 on ULN2003 board

CheapStepper stepper (8,9,10,11);

 // let's create a boolean variable to save the direction of our rotation
//int digitalPin = 8;
//int digitalPin = 9;
//int digitalPin = 10;
//int digitalPin = 11;
boolean moveClockwise = true;

int led = 13 ; // LED on arduino
int digitalPin = 3; // linear Hall magnetic sensor digital interface
int analogPin = A0; // linear Hall magnetic sensor analog interface
int digitalVal ; // digital readings
int analogVal; // analog readings
int stepperPin1 = 8;
int stepperPin2 = 9;
int stepperPin3 = 10;
int stepperPin4 = 11;

 
void setup() {

  // let's set a custom speed of 20rpm (the default is ~16.25rpm)
  // pinMode (led, OUTPUT);
  pinMode (digitalPin, INPUT);
  pinMode(analogPin, INPUT);
 // stepper.setRpm(20);
 
 
  /* Note: CheapStepper library assumes you are powering your 28BYJ-48 stepper
   * using an external 5V power supply (>100mA) for RPM calculations
   * -- don't try to power the stepper directly from the Arduino
   *
   * accepted RPM range: 6RPM (may overheat) - 24RPM (may skip)
   * ideal range: 10RPM (safe, high torque) - 22RPM (fast, low torque)
   */

  // now let's set up a serial connection and print some stepper info to the console
 

 
 
  /* you can uncomment the above line if you think your motor
   * is geared 63.68395:1 (measured) rather than 64:1 (advertised)
   * which would make the total steps 4076 (rather than default 4096)
   * for more info see: http://forum.arduino.cc/index.php?topic=71964.15
   */
   
}

void loop() {

 
  digitalVal = digitalRead(digitalPin) ;
if (digitalVal == LOW)
 {
 stepper.moveDegrees (moveClockwise,80);
 
 delay(1000);


 digitalWrite(stepperPin1,LOW );
digitalWrite(stepperPin2,LOW );
digitalWrite(stepperPin3,LOW );
digitalWrite(stepperPin4,LOW );


 
}


if (digitalVal == HIGH)
{

 moveClockwise = !moveClockwise; // reverse direction
    stepper.moveDegrees  (moveClockwise, 180);
 delay(1000);   

    // and now let's move another 90 degrees (a quarter-turn) clockwise

 
   
} }

groundFungus

Even after being ask, nicely, to read the forum guidelines you post badly formatted code without code tags.  How do we know that if we take the time to write helpful responses that you will not ignore them, too?

Robin2

Why not try the regular Stepper library that people here will be familiar with. Or the AccelStepper library if you need the extra functionality.

There are dozens of Forum Threads about 28BYJ-48 stepper motors - have you looked at any of them?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up