sincronismo arduino-reader

salve,
volevo esporvi un mio problema, sperando nel vostro aiuto.
Sto collegando un'antenna rfid con ingresso ed uscita ethernet ad un arduino uno con shield ethernet.
Sketch che contengono l'invio di un comando al reader, funzionano solo inserendo dei delay, come se i due terminali non fossero **"sincronizzati"**, e quindi, uno dei due necessitasse di maggiore tempo. Il mio problema, però, si pone con sketch che inviano comandi all'antenna dopo che da un sito web viene premuto un pulsante. Sito e arduino comunicano, ma l'antrenna non smepre comunica con arduino. Inserendo delay anche in questi programmi, come facevo con gli altri, non risolvo il problema.[/u]
Spero in una vostra soluzione...

Ciao,
essendo il tuo primo post, ti chiederei cortesemente di presentarti QUI (spiegando bene quali conoscenze hai di elettronica e di programmazione ... possibilmente evitando di scrivere solo una riga di saluto) e di leggere con attenzione il REGOLAMENTO ... Grazie.

Guglielmo

E cosa Ti aspetti da noi?

Che facciamo gli esorcisti e scacciamo per telepatia i spettri meligni dal Tuo Sketch?

Che schede hai, che Sketch usi?

Ciao Uwe

la scheda è un arduino uno, come scritto nel primo post.
lo sketch è il seguente:

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte ComActive[11]={0x0A,0x00,0x35,0x01,0x02,0x01,0x02,0x06,0x00,0xB1,0x63};
byte controllo=0xFFFFFFFF;
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 11, 13);
IPAddress server1(192, 168, 11, 3);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

char data;
String msg="";
int cmd=0;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  // start the Ethernet connection and the server:
  
  Ethernet.begin(mac, ip);
//  delay(1000);
  server.begin();
 // delay(1000);
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
 // delay(1000);
  EthernetClient client = server.available();
  if (client) {//delay(1000);
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        data = client.read();
        msg += data;
        Serial.write(data);
          
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (data == '\n' && currentLineIsBlank) {
          cmd = msg.indexOf("active");
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          //client.println("Refresh: 15");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          //client.println(cmd);
          if (cmd>0){
          client.println("Il reader e' passato in active mode");
          EthernetClient client1;
          //delay(1000);
          if (client1.connect(server1, 5000)) {
  
          //delay(1000);  
          Serial.println("connesso");
   
  }
  
           do {
   //* comando per far passare l'antenna in active mode
  //Serial.print("Invio il cmd per passare in active mode");
  //delay(1000);
  client.write(comActive, 11);
  delay(300);
  Serial.println(client.read(),HEX);
} while (controllo!=(client.read(),HEX));

          }
          else {
            client.println("Il reader non e' passato in active mode");
          }
          client.println("</html>");
          break;
        }
        if (data == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (data != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}

tutti i delay a commento, servono per far funzionare altri miei sketch che mandano i comandi al reader senza l'interfacciamento col sito.
Questo sketch dovrebbe far mandare il comando all'antenna dopo aver pigiato un pulsante su un sito.