HTML skatch Arduino YUN

Ciao a tutti, ho scritto co l'aiuto di alcuni esempi lo skatch seguente e l'ho caricato.

#include <Bridge.h>
 #include <YunServer.h>
 #include <YunClient.h>
 
// Listen on default port 5555, the webserver on the Yun
 // will forward there all the HTTP requests for us.
 YunServer server;
 
void setup() {
   Serial.begin(9600);
 
  // Bridge startup
   pinMode(13,OUTPUT);
   digitalWrite(13, LOW);
   Bridge.begin();
   digitalWrite(13, HIGH);
 
  // Listen for incoming connection only from localhost
   // (no one from the external network could connect)
   server.listenOnLocalhost();
   server.begin();
 }
 
void loop() {
   // Get clients coming from server
   YunClient client = server.accept();
 
  // There is a new client?
   if (client) {
     // Process request
     process(client);
 
    // Close connection and free resources.
     client.stop();
   }
 
  delay(50); // Poll every 50ms
 }
 
void process(YunClient client) {
   // read the command
   String command = client.readStringUntil('/');
 
  // is "digital" command?
   if (command == "digital") {
     digitalCommand(client);
   }
 
  // is "analog" command?
   if (command == "analog") {
     analogCommand(client);
   }
 
  // is "mode" command?
   if (command == "mode") {
     modeCommand(client);
   }
 }
 
void digitalCommand(YunClient client) {
   int pin, value;
 
  // Read pin number
   pin = client.parseInt();
 
  // If the next character is a '/' it means we have an URL
   // with a value like: "/digital/13/1"
   if (client.read() == '/') {
     value = client.parseInt();
     digitalWrite(pin, value);
   } 
  else {
     value = digitalRead(pin);
   }
 
  // Send feedback to client
   client.print(F("Pin D"));
   client.print(pin);
   client.print(F(" set to "));
   client.println(value);
 
  // Update datastore key with the current pin value
   String key = "D";
   key += pin;
   Bridge.put(key, String(value));
 }
 
void analogCommand(YunClient client) {
   int pin, value;
 
  // Read pin number
   pin = client.parseInt();
 
  // If the next character is a '/' it means we have an URL
   // with a value like: "/analog/5/120"
   if (client.read() == '/') {
     // Read value and execute command
     value = client.parseInt();
     analogWrite(pin, value);
 
    // Send feedback to client
     client.print(F("Pin D"));
     client.print(pin);
     client.print(F(" set to analog "));
     client.println(value);
 
    // Update datastore key with the current pin value
     String key = "D";
     key += pin;
     Bridge.put(key, String(value));
   }
   else {
     // Read analog pin
     value = analogRead(pin);
 
    // Send feedback to client
     client.print(F("Pin A"));
     client.print(pin);
     client.print(F(" reads analog "));
     client.println(value);
 
    // Update datastore key with the current pin value
     String key = "A";
     key += pin;
     Bridge.put(key, String(value));
   }
 }
 
void modeCommand(YunClient client) {
   int pin;
 
  // Read pin number
   pin = client.parseInt();
 
  // If the next character is not a '/' we have a malformed URL
   if (client.read() != '/') {
     client.println(F("error"));
     return;
   }
 
  String mode = client.readStringUntil('\r');
 
  if (mode == "input") {
     pinMode(pin, INPUT);
     // Send feedback to client
     client.print(F("Pin D"));
     client.print(pin);
     client.print(F(" configured as INPUT!"));
     return;
   }
 
  if (mode == "output") {
     pinMode(pin, OUTPUT);
     // Send feedback to client
     client.print(F("Pin D"));
     client.print(pin);
     client.print(F(" configured as OUTPUT!"));
     return;
   }
 
  client.print(F("error: invalid mode "));
   client.print(mode);
 }

Poi sempre con lo stesso metodo ho cresto il codice HTML sotto descritto e l'ho salvato con nome index.htm nella cartella www.

<html>
  <head>
    <title>Arduino Y&uacute;n I/O shield</title>
    <script type="text/lavascript">
	window.onload=caricastatoPin;
	function CaricastatoPin () {
	leggistato () ;
	}
	function leggiStato () {
	setTimeout (leggiStato, 2000);
	document.getElementById("descrizione").innerHTML = "---Attendi ... ---";
	server = "/arduino/stato/99";
	richiesta = new XMLHttpRequest ();
	richiesta.onreadystatechange = upateasincronoStato;
	richiesta.open("GET",server, true);
	richiesta.send(null);
	}
	function upateasincronoAnalog() {
	if ((richiesta.readystate == 4) && (richiesta.status == 200))
	}
	esito = richiesta.responseText;
	iparr = esito.split(",");
	PinType = iparr[0];
	PinNum = iparr[1];
	AnalogNum ="Analog" + PinNum;
	document.getElementById(AnalogNum).value = PinVal;
	document.getElementById("descrizione").innerHTML = esito;

 </script>
</head>

<input type="text" name="analogNum" id="analog0" value="0" readonly/>
</html>

Il tutto viene caricato correttamente all'interno della sd, e digitando su url adrduino.local/sd/davide (davide è il nome dello skatch) visualizzo la pagina html caricata ma non aggiorna il dato.

Mi potete dare una mano epr cortesia indicandomi dove ho sbagliato..
Grazie a tutti e buona domenica

Ti consiglio di controllare bene l'html, ci sono parecchi errori. :wink: