28byj-48 with ethernet?

Who can help me ?

I have 2 basic programs :
1° Led control over ethernet. Result = ok
(see file Led_control_ethernet)
2° Motor control with pushbuttons = ok
(see file Motor_control_pushbuttons)

No the problem:
When i make a combination of the 2 files then the result is not what i expect.
Who can help me to solve this question.
(i want to let turn the stepper, 28byj-48, to left over ethernet or with pushbutton and with the other choice turn right)

THX

Motor_control_pushbutton.ino (1.43 KB)

Led_control_ethernet.ino (4 KB)

Motor_Led_control_Ethernet.ino (5.1 KB)

Is pin 4 and/or pin 10 used for Ethernet or SD card ?

yes
May i not use those pins?

No! ]:) They are already in use for the Ethernet and SD card.

They are used to select an SPI device. Only of them may be active. Can you try to rearrange the pins ?

ok, I have half the solution. I have changed the pins and the program runs. :) If I run the program of the motor only , then it keeps spinning when I press the button 'on' . He stops when I press the stop. In the full program, the motor turns a few steps when I press 'white light on'. Why does it not run continue?

Hi,
I have changed my program.
Why does the motor only one step???

//for use with W5100 based ethernet shields
 
#include <SPI.h>
#include <Ethernet.h>
#include <CustomStepper.h>
 
// was in the basiccode
#include <Servo.h>
Servo myservo;  // create servo object to control a servo
CustomStepper stepper(5, 6, 7, 8, (byte[]){8, B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001}, 8, 4096, CW);
boolean rotate1 = false;
boolean rotatedeg = false;
boolean crotate = false;
int Wup = 0;
int Wdown = 0;
int Wstp = 0;
// pushbutton up on 9
#define up  9
// pushbutton down on 11
#define down  11
// pushbutton stp on 12
#define stp  12
 
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 10, 177 }; // ip in lan
byte gateway[] = { 192, 168, 10, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
int cntl = 0 ;
int white = 2 ;
int red = 3 ;
String readString;
 
//////////////////////
 
void setup(){
 
  pinMode(up, INPUT); 
  pinMode(down, INPUT); 
  pinMode(stp, INPUT); 
  
  stepper.setRPM(16);
  //sets the Steps Per Rotation, in this case it is 64 * the 283712/4455 annoying ger ratio
  //for my motor (it works with float to be able to deal with these non-integer gear ratios)
  stepper.setSPR(4096);
  
  pinMode(white, OUTPUT); //pin selected to control LED white
  pinMode(red, OUTPUT); //pin selected to control LED red
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  //the pin for the servo co
  //enable serial data print
  Serial.begin(9600);
  Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}
 
void loop(){
  // Create a client connection
  Serial.println ("cntl=");
  Serial.println (cntl);
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
 
        //read char by char HTTP request
        if (readString.length() < 100) {
 
          //store characters to string
          readString += c;
          //Serial.print(c);
        }
 
        //if HTTP request has ended
        if (c == '\n') {
 
          ///////////////
          Serial.println(readString); //print to serial monitor for debuging
 
          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();
 
          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
          client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
          client.println("<link rel='stylesheet' type='text/css' href='http://homeautocss.net84.net/a.css' />");
          client.println("<TITLE>Home Automation</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");
          client.println("<H1>Home Automation</H1>");
          client.println("<hr />");
          client.println("
");
         
          client.println("<a href=\"/?lightwon\"\">White light on</a>");
          client.println("<a href=\"/?lightwoff\"\">White light off</a>
");        
          client.println("
");
         
          client.println("<a href=\"/?lightron\"\">Red light on</a>");
          client.println("<a href=\"/?lightroff\"\">Red light off</a>
");        
 
          client.println("</BODY>");
          client.println("</HTML>");
 
          delay(1);
          //stopping client
          client.stop();
 
          ///////////////////// control arduino pin
          if(readString.indexOf("?lightwon") >0)//checks for on
          {
            digitalWrite(white, HIGH);    // set pin 6 high
            Serial.println("Led White On");
            cntl = 1 ;
            Serial.println("here I pass ....");
            stepper.setDirection (CW) ;
            stepper.rotate(2);
          }
          else{
          if(readString.indexOf("?lightwoff") >0)//checks for off
          {
            digitalWrite(white, LOW);    // set pin 6 low
            Serial.println("Led White Off");
            cntl = 0 ;
          }
          }
          if(readString.indexOf("?lightron") >0)//checks for on
          {
            digitalWrite(red, HIGH);    // set pin 7 high
            Serial.println("Led Red On");
            cntl = 2 ;
          }
          else{
          if(readString.indexOf("?lightroff") >0)//checks for off
          {
            digitalWrite(red, LOW);    // set pin 7 low
            Serial.println("Led Red Off");
            cntl = 0 ;
          }
          }
          //clearing string for next read
          readString="";
        }
// if (cntl == 1 ) {
//   Serial.println("here I pass");
//   stepper.setDirection (CW) ;
//   stepper.rotate();
//   delay(500);
// }
      }
    }
  }
stepper.run();
}