Salve a tutti
Ho modificato un codice trovato in rete, lasciando solo l'apri porta.
Il problema è che ogni volta che carico la pagina web, parte l'impulso per il relè facendolo azionare, senza che azioni l'apposito tasto "APRI".
Come si può ovviare a questo ..........
Grazie e buon 1° Maggio a Tutti Voi
![]()
/*
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("DOMOTICSEMMY");
client.println("
SEMMY ROBY
"); {client.println("
");
client.print("SAN LORENZO NUOVO");
client.println("
");
client.print("Questa pagina permette di aprire la tua porta di casa");
client.println("
");
client.println("
APRI PORTA -
");client.println("
");
client.print("
APRI
");client.println("
"); }
client.println("
");
client.print("Programmazione effettuata da SemmyRoby@0114 su Board Arduino UNO con ethernet shield");
client.println("");
//clearing string for next read
readString="";
//stopping client
client.stop();
}
}
}
}
}