nid69ita:
Il codice devi postarlo negli appositi tag. Altrimenti alcune parti del codice possono essere visualizzate male (vengono interpretati come attributi della pagina).
Vedi sezione 7 del regolamento, spiega come fare.
/*
Semmyroby
Mag 2014
*/
#include <String.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x3F, 0x3F }; //physical mac address
byte ip[] = { 192, 168, 1, 36 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // ip in lan
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString; //string
boolean LED1ON = false; //LED1 status flag
boolean LED2ON = false; //LED2 status flag
boolean LED3ON = false; //LED3 status flag
boolean login=false;
/*pir*/
int segnal = 2;
int ledGreen = 4;
int ledRed = 7;
void setup(){
Ethernet.begin(mac, ip, gateway, subnet);
pinMode(3, OUTPUT); // Apri Porta
Serial.begin(9600);
}
void loop(){
/*inizio client*/
EthernetClient client = server.available();
if (client) {
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
readString.concat(c);
if (c == '\n' && currentLineIsBlank) {
Serial.print(readString);{
if(readString.indexOf("L=1") > 0) {
digitalWrite(3, HIGH); // set the LED on
LED1ON = true;
delay(500);
digitalWrite(3, LOW); // set the LED OFF
LED1ON = false;
}
}
// INIZIO DICHIARAZIONE PAGINA HTML
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("<html><head><title>DOMOTICSEMMY</title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' ></head><body>");
client.println("<hr /><h1>SEMMY ROBY</h1>"); {
client.println("<hr />");
client.print("<span>SAN LORENZO NUOVO</span>");
client.println("<hr />");
client.print("<span>Questa pagina permette di aprire la tua porta di casa</span>");
client.println("<hr />");
client.println("<h1>APRI PORTA - </h1>");
client.println("
");
client.print("<h2><a href='/?L=1'>APRI</a></h2>");
client.println("<hr />"); }
client.println("<hr />");
client.print("<span>Programmazione effettuata da SemmyRoby@0114 su Board Arduino UNO con ethernet shield</span>");
client.println("</body></html>");
//clearing string for next read
readString="";
//stopping client
client.stop();
}
}
}
}
}
Grazie
![]()