please spent some time to get proper layout - CTRL-T does help you
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0E, 0xCE, 0xA1 }; //physical mac address
byte ip[] = {
192, 168, 0, 2 }; // ip in lan
byte gateway[] = {
192, 168, 0, 1 }; // internet access via router
byte subnet[] = {
255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;
//////////////////////
int switchhh = 2;
int pwm = 5;
int dir = 7;
int valswitch = 0;
void setup()
{
//Setup Channel A from Motor shield
pinMode(pwm, OUTPUT); //Initiates Motor Channel A pin
pinMode(dir, OUTPUT); //Initiates Brake Channel A pin
//Start Ethernet
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600);
Serial.println("server multi pin button test 1.0"); // so I can keep track of what is loaded
attachInterrupt(1, motor_stop, RISING);
}
void loop()
{
// Create a client connection
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><HEAD><TITLE>Projet d'étude : ARDUINO et Contrôle de panneau solaire</TITLE></HEAD>");
client.println("<BODY>");
client.println("<H3>Projet d'étude : ARDUINO et Contrôle de panneau solaire</H3>");
// DIY buttons
client.println("<a href=/?up2 >Monter</a> <a href=/?down3 >Descendre</a> <a href=/?stop4 >STOP</a>");
client.println("</BODY></HTML>");
delay(1);
//stopping client
client.stop();
///////////////////// control arduino pin
if(readString.indexOf('2') > 0)//checks for 2 MONTER
{
Serial.println("Bouton monter appuyer !!");
digitalWrite(dir, HIGH);
analogWrite(pwm, 255);
delay(3000);
m_stop();
Serial.println("Bouton monter appuyer !! FIN BOUCLE");
}
if(readString.indexOf('3') > 0)//checks for 3 DESCENDRE
{
Serial.println("Bouton descendre appuyer !!");
digitalWrite(dir, LOW);
analogWrite(pwm, 255);
}
if(readString.indexOf('4') > 0)//checks for 3 STOP
{
Serial.println("Bouton STOP appuyer !!");
m_stop();
Serial.println("Bouton STOP appuyer !! FIN BOUCLE");
}
valswitch = digitalRead(switchhh);
if (valswitch == HIGH)
{
//clearing string for next read
readString="";
}
}
}
}
}
}
void motor_stop()
{
Serial.println("motor_stop begin");
m_stop();
Serial.println("motor_stop end");
}
void m_stop()
{
Serial.println("m_stop start");
digitalWrite(pwm, 0);
Serial.println("m_stop end");
}
and please use only comments when in sync with the code >>> if(readString.indexOf('4') > 0)//checks for 3 STOP
quick code review shows no direct errors. Are you running out of RAM?