Esempio
porte da 10 a 99
http://192.168.2.177/110 >> on porta 10
http://192.168.2.177/010 >> off porta 10
...
http://192.168.2.177/199 >> on porta 99
http://192.168.2.177/099 >> off porta 99
porte da 0 a 9
http://192.168.2.177/100 >> on porta 0
http://192.168.2.177/000 >> off porta 0
...
http://192.168.2.177/109 >> on porta 9
http://192.168.2.177/009 >> off porta 9
Non ho lo shifter quindi dovrai sostituire i digitalWrite(port,0); con le tue righe, l'ip e company, ma il principio è lo stesso
shifter.setPin(Indirizzo, Comando);
shifter.write();
delay(3000);
shifter.clear();
shifter.write();
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 2, 177 };
EthernetServer server(80);
String query;
byte out_1 = 40;
byte out_2 = 41;
byte out_3 = 42;
byte out_4 = 43;
void setup(){
Ethernet.begin(mac, ip);
pinMode(out_1, OUTPUT);
pinMode(out_2, OUTPUT);
pinMode(out_3, OUTPUT);
pinMode(out_4, OUTPUT);
}
void loop()
{
EthernetClient client = server.available();
if (client)
{
boolean currentLineIsBlank = true;
while (client.connected())
{
if (client.available())
{
char c = client.read();
query.concat(c);
if (c == '\n' && currentLineIsBlank)
{
String Digi_port = query.substring(6,8) + "0";
char thisChar[Digi_port.length()];
Digi_port.toCharArray(thisChar, Digi_port.length());
int port = atoi(thisChar);
String on_off = query.substring(5,6);
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("<html><head><title>ARDUINO WEB</title></head><body>");
if (on_off != "0" && on_off != "1")
{
client.println("ERRORE IMMISSIONE DATO !!
");// DEBUG
}
else
{
client.println("Stringa inviata ad Arduino >> " + query + "
");// DEBUG
client.println("Stringa ricevuta da Arduino parse >> " + (String)port + "
");// DEBUG
client.println("Comando da eseguire sulla porta " + (String)port + " >> "+ on_off + "
");// DEBUG
if(on_off == "0") digitalWrite(port,0);
if(on_off == "1") digitalWrite(port,1);
}
client.println("</body></html>");
query="";
delay(1);
client.flush();
client.stop();
}
}
}
}
}
L'ho fatto sul mio quindi deve andare anche sul tuo, fammi sapere ciao