#include <EtherCard.h>
static byte mymac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte Ethernet::buffer[600];
boolean L1,L2,L3,L4;
const char *sito="http://mio_sito";
void setup () {
ether.begin(sizeof Ethernet::buffer, mymac, 53);
ether.hisport = 80;
ether.dhcpSetup();
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
// DDRD = B00111100;
//PORTD |= B00000000;
L1=L2=L3=L4 = true;
}
void loop() {
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if(pos) {
if(strstr((char *)Ethernet::buffer + pos, "GET /R1") != 0) {
L1 = !L1;
digitalWrite(2, L1);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /R2") != 0) {
L2 = !L2;
digitalWrite(3, L2);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /R3") != 0) {
L3 = !L3;
digitalWrite(4, L3);
}
if(strstr((char *)Ethernet::buffer + pos, "GET /R4") != 0) {
L4 = !L4;
digitalWrite(5, L4);
}
BufferFiller bfill = ether.tcpOffset();
bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
"<title>Ardumino 1.0</title>"));
bfill.emit_p (PSTR("<a href=\"/R1\"><img src=\"$S/lam-$F.jpg\" width=50% height=40%>"), sito, L1 ? PSTR ("off") : PSTR ("on"));
bfill.emit_p (PSTR("<a href=\"/R2\"><img src=\"$S/cor-$F.jpg\" width=50% height=40%>"), sito, L2 ? PSTR ("off") : PSTR ("on"));
bfill.emit_p (PSTR("<a href=\"/R3\"><img src=\"$S/wd-$F.jpg\" width=50% height=40%>"), sito, L3 ? PSTR ("off") : PSTR ("on"));
bfill.emit_p (PSTR("<a href=\"/R4\"><img src=\"$S/hdd-$F.jpg\" width=50% height=40%>"), sito, L4 ? PSTR ("off") : PSTR ("on"));
bfill.emit_p(PSTR("
<a href=\"/\"><img src=\"$S/agg.png\" width=15% height=15%>"), sito);
ether.httpServerReply(bfill.position());
}
}
questo è il codice che sto usando
ora dovrei aggiungere un quinto rele comandato da un quinto tasto
una volta pigiato il quinto tasto il rele si deve eccitare per un secondo e poi tornare off
come posso fare?
grazie