moving stepper motor 28byj48

Hello

i create an application which connects with a server and finally with Arduino and stepper motor. everything is fine Arduino receives 1 for moving stepper clockwise and 0 counterclockwise.

I found that code and work fine for moving the stepper motor

//declare variables for the motor pins
int motorPin1 = 8; // Blue   - 28BYJ48 pin 1
int motorPin2 = 9; // Pink   - 28BYJ48 pin 2
int motorPin3 = 10; // Yellow - 28BYJ48 pin 3
int motorPin4 = 11; // Orange - 28BYJ48 pin 4
                     // Red    - 28BYJ48 pin 5 (VCC)

int motorSpeed ;     //variable to set stepper speed



//////////////////////////////////////////////////////////////////////////////
void setup() {
//declare the motor pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(motorPin3, OUTPUT);
pinMode(motorPin4, OUTPUT);
Serial.begin(9600);
}

//////////////////////////////////////////////////////////////////////////////
void loop(){


//  if (2 < 3){               // if potentiometer reads 0 to 535 do this
 motorSpeed = (33);  //scale potValue to be useful for motor
 clockwise();                     //go to the ccw rotation function
//  }
//  else {                             //value of the potentiometer is 512 - 1024
//    motorSpeed = (33); //scale potValue for motor speed
//    counterclockwise(); //go the the cw rotation function
//  }
}

//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 1 to 4
//delay "motorSpeed" between each pin setting (to determine speed)

void counterclockwise (){
// 1
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(motorSpeed);
// 2
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay (motorSpeed);
// 3
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, LOW);
delay(motorSpeed);
// 4
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(motorSpeed);
// 5
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, LOW);
delay(motorSpeed);
// 6
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin4, HIGH);
delay (motorSpeed);
// 7
digitalWrite(motorPin1, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(motorSpeed);
// 8
digitalWrite(motorPin1, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin4, HIGH);
delay(motorSpeed);
}

//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 4 to 1
//delay "motorSpeed" between each pin setting (to determine speed)

void clockwise(){
// 1
digitalWrite(motorPin4, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(motorSpeed);
// 2
digitalWrite(motorPin4, HIGH);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay (motorSpeed);
// 3
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, LOW);
delay(motorSpeed);
// 4
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, HIGH);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin1, LOW);
delay(motorSpeed);
// 5
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin1, LOW);
delay(motorSpeed);
// 6
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, HIGH);
digitalWrite(motorPin1, HIGH);
delay (motorSpeed);
// 7
digitalWrite(motorPin4, LOW);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, HIGH);
delay(motorSpeed);
// 8
digitalWrite(motorPin4, HIGH);
digitalWrite(motorPin3, LOW);
digitalWrite(motorPin2, LOW);
digitalWrite(motorPin1, HIGH);
delay(motorSpeed);
}

however

i place that code in my project and stepper motor didnt rotate. the "1" and "0" transmited fine to Arduino.


could you please help me.

thank you in advance

/*
Arduino WiFi Script Server
 Created October 20, 2013
 Mikael Kindborg, Evothings AB
 TCP socket server that accept commands for basic scripting
 of the Arduino board.
 This example is written for a network using WPA encryption.
 For WEP or WPA, change the Wifi.begin() call accordingly.
 
 */
#include <SPI.h>
#include <WiFi.h>
#include <SoftwareSerial.h>

// This Arduino example demonstrates bidirectional operation of a 
// 28BYJ-48, which is readily available on eBay, using a ULN2003 
// interface board to drive the stepper. The 28BYJ-48 motor is a 4-
// phase, 8-beat motor, geared down by a factor of 68. One bipolar 
// winding is on motor pins 1 & 3 and the other on motor pins 2 & 4. 
// Refer to the manufacturer's documentation of  Changzhou Fulling 
// Motor Co., Ltd., among others.  The step angle is 5.625/64 and the 
// operating Frequency is 100pps. Current draw is 92mA.  In this 
// example, the speed and direction of the stepper motor is determined 
// by adjusting a 1k-ohm potentiometer connected to Arduino pin A2. 
// When the potentiometer is rotated fully counterclockwise, the motor 
// will rotate at full counterclockwise speed. As the potentiometer is 
// rotated clockwise, the motor will continue to slow down until is 
// reaches its minimum speed at the the potentiometer's midpoint value . 
// Once the potentiometer crosses its midpoint, the motor will reverse 
// direction. As the potentiometer is rotated further clockwise, the speed   
// of the motor will increase until it reaches its full clockwise rotation 
// speed when the potentiometer has been rotated fully clockwise.
////////////////////////////////////////////////

//declare variables for the motor pins
int motorPin1 = 8;	// Blue   - 28BYJ48 pin 1
int motorPin2 = 9;	// Pink   - 28BYJ48 pin 2
int motorPin3 = 10;	// Yellow - 28BYJ48 pin 3
int motorPin4 = 11;	// Orange - 28BYJ48 pin 4
// Red    - 28BYJ48 pin 5 (VCC)

int motorSpeed =5;     //variable to set stepper speed


// Your network SSID (network name).
// TODO: Enter the name of your wifi network here.
char ssid[] = "Tzavelas";

// Your network password.
// TODO: Enter the password of your wifi network here.
char pass[] = "mypass";

// Your network key Index number (needed only for WEP).
int keyIndex = 0;

// Server status flag.
int status = WL_IDLE_STATUS;

// Create WiFi listening on the given port.
WiFiServer server(4001);

void setup()
{
  // Start serial communication with the given baud rate.
  // NOTE: Remember to set the baud rate in the Serial
  // monitor to the same value.



  //declare the motor pins as outputs
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
  Serial.begin(9600);


  // Wait for serial port to connect. Needed for Leonardo only
  while (!Serial) { 
    ; 
  }

  // Check for the presence of the WiFi shield.
  if (WiFi.status() == WL_NO_SHIELD)
  {
    // If no shield, print message and exit setup.
    Serial.println("WiFi shield not present");
    status = WL_NO_SHIELD;
    return;
  }

  String version = WiFi.firmwareVersion();
  if (version != "1.1.0")
  {
    Serial.println("Please upgrade the firmware");
  }

  // Connect to Wifi network.
  while (status != WL_CONNECTED)
  {
    Serial.print("Connecting to Network named: ");
    Serial.println(ssid);

    // Connect to WPA/WPA2 network. Update this line if
    // using open or WEP network.
    status = WiFi.begin(ssid, pass);

    // Wait for connection.
    delay(1000);
  }

  // Start the server.
  server.begin();

  // Print WiFi status.
  printWifiStatus();
}

void loop()
{
  // Check that we are connected.
  if (status != WL_CONNECTED)
  {
    return;
  }

  // Listen for incoming client requests.
  WiFiClient client = server.available();
  if (!client)
  {
    return;
  }

  Serial.println("Client connected");

  String request = readRequest(&client);
  //executeRequest(&client, &request);

  // Close the connection.
  //client.stop();

  Serial.println("Client disonnected");
}

// Read the request line. The string from the JavaScript client ends with a newline.
String readRequest(WiFiClient* client)
{
  String request = "";

  // Loop while the client is connected.
  while (client->connected())
  {
    // Read available bytes.
    while (client->available())
    {
      // Read a byte.
      char c = client->read();

      // Print the value (for debugging).
      Serial.write(c);

      if (c == '1'){      

        //int microsteps=100;
        // for (int i = 0; i<microsteps; i++)       // Iterate for 4000 microsteps.

        unsigned long start = millis();
        while (true) 

        {
          motorSpeed = (5);  //scale potValue to be useful for motor
          clockwise(); 
          Serial.write("move up");
        }

      }
      else {      

        int microsteps=100;
        for (int i = 0; i<microsteps; i++)       // Iterate for 4000 microsteps.
        {
          motorSpeed = (5);  //scale potValue to be useful for motor
          counterclockwise(); //go the the cw rotation function
          Serial.write("move down");  
        }

      }

      // Exit loop if end of line.
      if ('\n' == c)
      {

        return request;
        // Add byte to request line.
        request += c;

      }

    }
  }

}


void printWifiStatus()
{
  Serial.println("WiFi status");

  // Print network name.
  Serial.print("  SSID: ");
  Serial.println(WiFi.SSID());

  // Print WiFi shield IP address.
  IPAddress ip = WiFi.localIP();
  Serial.print("  IP Address: ");
  Serial.println(ip);

  // Print the signal strength.
  long rssi = WiFi.RSSI();
  Serial.print("  Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}
//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 1 to 4
//delay "motorSpeed" between each pin setting (to determine speed)

void counterclockwise (){
  // 1
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 2
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay (motorSpeed);
  // 3
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 4
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 5
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 6
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, HIGH);
  delay (motorSpeed);
  // 7
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(motorSpeed);
  // 8
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(motorSpeed);
}

//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 4 to 1
//delay "motorSpeed" between each pin setting (to determine speed)

void clockwise(){
  // 1
  digitalWrite(motorPin4, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 2
  digitalWrite(motorPin4, HIGH);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, LOW);
  delay (motorSpeed);
  // 3
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 4
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 5
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 6
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin1, HIGH);
  delay (motorSpeed);
  // 7
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, HIGH);
  delay(motorSpeed);
  // 8
  digitalWrite(motorPin4, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, HIGH);
  delay(motorSpeed);
}

my code is in the second post..

Please read How to use the Forum and please use the code button </>

so your code looks like this

and I can easily select it and copy it to my text editor.

In your Orginal Post you said

everythinf is fine Arduino receives 1 for moving stepper clockwise and 0 counterclockwise

and

however

i place that code in my project and stepper motor didnt rotate

Which statement is correct ?

Have you been able to write a program that makes the stepper move ?

...R

Hello and thank you for you response

what i did was to find two pieces of code one to communicate with my server and receives the 1 and 0 char. the other was to move the stepper motor. alono both work fine. however together the stepper motor starts (i feel the vibration) bu cannot move...

GO BACK
EDIT your post bottom right of the page
ADD a left bracket "[" followed by the word code , then a right bracket.
after the last line of your code

ADD a left bracket "[" followed by the word /code , then a right bracket.

then SAVE your post.

Most on here will not even look at your code or reply when you dump your code into the forum

autoformat your code in the IDE

i did that
sorry I am a new at forum

Can you please help me!!!

the problem is probably at this part of the code inside the if statement. i try different ways to fix that but nothing happened.

if (c == '1'){     

        //int microsteps=100;
        // for (int i = 0; i<microsteps; i++)       // Iterate for 4000 microsteps.

        unsigned long start = millis();
        while (true)

        {
          motorSpeed = (5);  //scale potValue to be useful for motor
          clockwise();
          Serial.write("move up");
        }

      }
      else {     

        int microsteps=100;
        for (int i = 0; i<microsteps; i++)       // Iterate for 4000 microsteps.
        {
          motorSpeed = (5);  //scale potValue to be useful for motor
          counterclockwise(); //go the the cw rotation function
          Serial.write("move down"); 
        }

      }

Why don't you use the Stepper or AccelStepper library to save yourself the trouble of writing all that clockwise() and counterclockwise() stuff ?

How many steps does the motor move for a single call to (say) clockwise()

As far as I can figure out this code

  // Check that we are connected.
  if (status != WL_CONNECTED)
  {
    return;
  }

will cause the Arduino to hang without making any attempt to reconnect if there is no connection. Is that what you want?

...R

i use that code. it is very weird. this code works...

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);

// the previous reading from the analog input


void setup()
{
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(100);
}

void loop()
{

  stepper.step(100);

}

however this does not.
i am start thinking might be a power problem because 5v are taken by motor and there is also the wifi shield.

#include <Stepper.h>
#include <WiFi.h>
#include <SoftwareSerial.h>


// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);

// the previous reading from the analog input
int previous = 1000;

// Your network SSID (network name).
// TODO: Enter the name of your wifi network here.
char ssid[] = "Tzavelas";

// Your network password.
// TODO: Enter the password of your wifi network here.
char pass[] = "mypass";

// Your network key Index number (needed only for WEP).
int keyIndex = 0;

// Server status flag.
int status = WL_IDLE_STATUS;

// Create WiFi listening on the given port.
WiFiServer server(4001);
void setup()
{
  Serial.begin(9600);


  // Wait for serial port to connect. Needed for Leonardo only
  while (!Serial) { 
    ; 
  }

  // Check for the presence of the WiFi shield.
  if (WiFi.status() == WL_NO_SHIELD)
  {
    // If no shield, print message and exit setup.
    Serial.println("WiFi shield not present");
    status = WL_NO_SHIELD;
    return;
  }

  String version = WiFi.firmwareVersion();
  if (version != "1.1.0")
  {
    Serial.println("Please upgrade the firmware");
  }

  // Connect to Wifi network.
  while (status != WL_CONNECTED)
  {
    Serial.print("Connecting to Network named: ");
    Serial.println(ssid);

    // Connect to WPA/WPA2 network. Update this line if
    // using open or WEP network.
    status = WiFi.begin(ssid, pass);

    // Wait for connection.
    delay(1000);
  }

  // Start the server.
  server.begin();
  WiFiClient client = server.available();

  stepper.setSpeed(30);
}

void loop()
{

  // Listen for incoming client requests.
  WiFiClient client = server.available();

  delay(1000);



  char c = client.read();


  Serial.write(c);

  if (c == '1'){      




    stepper.step(previous);
    Serial.write("move up");  



  }
  else if (c == '0'){      



    stepper.step(previous);
    Serial.write("move down");  


  }


}

XenofonTza:
i use that code. it is very weird. this code works...

i am start thinking might be a power problem because 5v are taken by motor and there is also the wifi shield.

Simple things first ...

You should not be powering any motor from the Arduino 5v pin with either of your programs. Give the motor a separate power supply with the GND connected to the Arduino GND.

Secondly ...
When you say "this code works" and "this does not." you are not giving us any useful information. What does the non-working code do, and what should it do?

Thirdly ...
What is different about the programs in Reply #10 compared to the earlier ones? What have you changed? What has been the result of the changes ?

...R

thnx for your reply

  1. I power the motor using 5v power supply of Arduino

  2. I get rid of clockwise functions as you suggest. The first piece of code just move the stepper using stepper.step(100) and work fine.

The second one I create a socket between a server and the Arduino and I send 1 and 0 to set different direction to the motor. The Arduino receives the messages because I can see them on the screen. However stepper only vibrates. I cannot find any place I made a mistake in the code.
…So probably is the power..

  1. I changed the way to move the motor but the result remain the same.

XenofonTza:
thnx for your reply

  1. I power the motor using 5v power supply of Arduino

DON'T

  1. I get rid of clockwise functions as you suggest. The first piece of code just move the stepper using stepper.step(100) and work fine.

Post the code

The second one I create a socket between a server and the Arduino and I send 1 and 0 to set different direction to the motor. The Arduino receives the messages because I can see them on the screen. However stepper only vibrates. I cannot find any place I made a mistake in the code.

Post the code

  1. I changed the way to move the motor but the result remain the same.

Draw a wiring diagram and post a photo of it.

You continue to assume we can give you advice without having all the information in front of us. We can't.

...R

  1. I get rid of clockwise functions as you suggest. The first piece of code just move the stepper using stepper.step(100) and work fine.

Post the code

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);

// the previous reading from the analog input


void setup()
{
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(100);
}

void loop()
{

  stepper.step(100);

}

The second one I create a socket between a server and the Arduino and I send 1 and 0 to set different direction to the motor. The Arduino receives the messages because I can see them on the screen. However stepper only vibrates. I cannot find any place I made a mistake in the code.

Post the code

#include <Stepper.h>
#include <WiFi.h>
#include <SoftwareSerial.h>


// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);

// the previous reading from the analog input
int previous = 1000;

// Your network SSID (network name).
// TODO: Enter the name of your wifi network here.
char ssid[] = "Tzavelas";

// Your network password.
// TODO: Enter the password of your wifi network here.
char pass[] = "mypass";

// Your network key Index number (needed only for WEP).
int keyIndex = 0;

// Server status flag.
int status = WL_IDLE_STATUS;

// Create WiFi listening on the given port.
WiFiServer server(4001);
void setup()
{
  Serial.begin(9600);


  // Wait for serial port to connect. Needed for Leonardo only
  while (!Serial) {
    ;
  }

  // Check for the presence of the WiFi shield.
  if (WiFi.status() == WL_NO_SHIELD)
  {
    // If no shield, print message and exit setup.
    Serial.println("WiFi shield not present");
    status = WL_NO_SHIELD;
    return;
  }

  String version = WiFi.firmwareVersion();
  if (version != "1.1.0")
  {
    Serial.println("Please upgrade the firmware");
  }

  // Connect to Wifi network.
  while (status != WL_CONNECTED)
  {
    Serial.print("Connecting to Network named: ");
    Serial.println(ssid);

    // Connect to WPA/WPA2 network. Update this line if
    // using open or WEP network.
    status = WiFi.begin(ssid, pass);

    // Wait for connection.
    delay(1000);
  }

  // Start the server.
  server.begin();
  WiFiClient client = server.available();

  stepper.setSpeed(30);
}

void loop()
{

  // Listen for incoming client requests.
  WiFiClient client = server.available();

  delay(1000);



  char c = client.read();


  Serial.write(c);

  if (c == '1'){     




    stepper.step(previous);
    Serial.write("move up"); 



  }
  else if (c == '0'){     



    stepper.step(previous);
    Serial.write("move down"); 


  }


}

My guess is that there is a problem with your wiring and you have not made the drawing of your wiring that I requested. Photos of your hardware do not convey the necessary information.

When you run your program are the messages "move up" and "move down" displayed appropriately ?

In your working program you are asking the motor to move 100 steps. Why are you using 1000 steps in the non-working program? What happens if you try 100 steps ?

...R

My guess is that there is a problem with your wiring and you have not made the drawing of your wiring that I requested. Photos of your hardware do not convey the necessary information.

it cant be any problem with that because at first piece of code everything works fine

When you run your program are the messages "move up" and "move down" displayed appropriately ?

YES!!!!

In your working program you are asking the motor to move 100 steps. Why are you using 1000 steps in the non-working program? What happens if you try 100 steps ?

i change the values lots of times. the motor just vibrates!!

XenofonTza:
it cant be any problem with that because at first piece of code everything works fine

I assume, then, that you tried the working program on the EXACT same hardware as the non-working program.

I still want to see a wiring diagram in case there is a power supply problem when you use the extra hardware.

I will have another look at your code.

...R

I still want to see a wiring diagram in case there is a power supply problem when you use the extra hardware.

the hardware remains the same both pieces of code

Another thought has crossed my mind. Perhaps the Stepper library and the WiFi library don't like each other. Conflicts between Arduino libraries are common.

Maybe I was wrong to suggest using it. But I think you said you had problems with your earlier non-library code.

Can you try using the functions clockwise() and counterclockwise() from the code in Reply #1 with the other parts of the second program in Reply #14. That will be simpler for me to understand than the code in Reply #1.

...R