Parce qu'un seul BIP pour 2 voitures c'est relou
Parce que Foncia facture le 2ème BIP
Parce que c'est cool :)
Parce que Mailjet m’a filé l'idée au TakeOff Talks
#include <Ethernet.h>
byte _mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress _ip(192,168,1,200);
EthernetServer _server(8086);
const int _pin = 7;
void setup() {
pinMode(_pin, OUTPUT);
Ethernet.begin(_mac, _ip);
_server.begin();
// start the Ethernet connection
if (Ethernet.begin(_mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// DHCP failed, so use a fixed IP address:
Ethernet.begin(_mac, _ip);
}
}
void loop() {
EthernetClient _client = _server.available(); // listen for incoming clients
if (_client) {
boolean _currentLineIsBlank = true; // an http request ends with a blank line
while (_client.connected()) {
if (_client.available()) {
char _c = _client.read();
if (_c == '\n' && _currentLineIsBlank) {
// received a newline character & line is blank: http request has ended
digitalWrite(_pin, HIGH);
delay(500);
digitalWrite(_pin, LOW);
...
break;
}
if (_c == '\n') {
_currentLineIsBlank = true; // is a new line
}
else if (_c != '\r') {
_currentLineIsBlank = false; // is a character on current line
}
}
}
delay(1); // give the web browser time to receive the data
_client.stop(); // close the connection
}
}
digitalWrite(_pin, HIGH);
delay(500);
digitalWrite(_pin, LOW);
_client.println("HTTP/1.1 200 OK"); // send a standard http response header
_client.println("Content-Type: text/html");
_client.println("Connection: close"); // the connection will be closed after completion of the response
_client.println();
_client.println("<!DOCTYPE HTML>");
_client.println("<html lang='fr'>");
_client.println("<head>");
_client.println(" <meta charset='utf-8'>");
_client.println(" <title>BIP</title>");
_client.println(" <meta name='viewport' content='width=device-width, initial-scale=1.0'>");
_client.println("</head>");
_client.println("<body style='background:#535354'>");
_client.println(" <div style='text-align:center;color:#fff;font-size:2em'>OUVERT</div>");
_client.println("</body>");
_client.println("</html>");
break;