loading
Aim:

Switch relays from the ethernet or the internet, using your mobile, tablet or computer with a nice graphical user interface.

Update V4.06
Please read the below steps to Step 2 if you are viewing this article for the first time.
Please go to step 3 for the latest revision which is V4.06
A user modified version with logon option is placed in step 5 for easy download.

Material:

    * Arduino MEGA 2560
    * Arduino Ethernet Shield
    * Relay board
    * RJ45 cable


Tools:

    * Arduino Software version 1.0.1 (downloadable from Arduino Website )
    * A / B USB cable


Infrastructure:

    * Internet access with fixed IP for Arduino
    * Access to your router to share the port for internet access
    * Testing devices - your pc, mobile etc


Disclaimer:

    * This project was tested with iPhone 3GS, iPad 2 and MacBook Pro running Safari and PC running Safari, Firefox, Opera and IE.
    * This project was created on October 2012 with the mentioned material.
    * Binary sketch size: 22,322 bytes (of a 258,048 byte maximum).
    * This sketch does not offer any sort of authentification, therefore if required to be used from outside the network or from the internet, I suggest to configure your network to connect trough VPN. Nowadays many routers and smartphones support VPN.



Step 1: Ethernet Switching - with Arduino - Description

Description:

    * With this project, I had not included any images, or links to images from the internet. It only make use of CSS3 and HTML5.
    * The simulated LEDs are created from CSS3 code.
    * Some browsers does not make full use of CSS3 and HTML5. Thus I suggest using Safari.
<p>Hi. Good Day.</p><p>Can you make this same code to be used with the Arduino IDE but with a board nodeMCU ESP8266 DEV KIT 1.0?</p>
<p>How connect thermistor??</p><p>// Connecting a 10K3 Thermistor to the Arduino Input</p><p>// +5V �&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;[10Kohms]&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;[Thermistor]&mdash;&mdash;� 0V</p><p>// To Arduino IP �&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;|</p><p>I do not understand this scheme :(</p>
<p>Am made as per you given and it works perfect. But i want to use many applicant and also change name of applicant .please give me instructions.</p>
<p>I really love the look of your interface, and have been trying to implement it on my own set up. I have a DHT22, and i2c relays (16 on 2 shields). For some reason, I cannot get my DHT22 readings to appear on the webpage above the buttons, nor can I get the button styles to work. </p><p>I am posting my code here, not to be rude, but in the hopes someone can help out. I would even reimburse! :-)</p><p>#include &lt;SPI.h&gt;<br>#include &quot;Ethernet.h&quot;<br>#include &quot;WebServer.h&quot;<br>#include &quot;Wire.h&quot;<br>#include &lt;DHT.h&gt;<br><br>#define DHTPIN 2<br>#define DHTTYPE DHT22 // AM2302<br><br>DHT dht(DHTPIN, DHTTYPE);<br><br>#define SHIELD_1_I2C_ADDRESS 0x20 // 0x20 is the address with all jumpers removed<br>#define SHIELD_2_I2C_ADDRESS 0x21 // 0x21 is the address with a jumper on position A0<br><br>#define MAC_I2C_ADDRESS 0x50 // Microchip 24AA125E48 I2C ROM address<br><br>/* CHANGE THIS TO YOUR OWN UNIQUE VALUE. The MAC number should be<br> * different from any other devices on your network or you'll have<br> * problems receiving packets. Can be replaced automatically below<br> * using a MAC address ROM. */<br>static uint8_t mac[] = { 0x00, 0x1E, 0xC0, 0xF8, 0x9E, 0x24 };<br><br>/* CHANGE THIS TO MATCH YOUR HOST NETWORK. Most home networks are in<br> * the 192.168.0.XXX or 192.168.1.XXX subrange. Pick an address<br> * that's not in use and isn't going to be automatically allocated by<br> * DHCP from your router. Can be replaced automatically using DHCP. */<br>static uint8_t ip[] = { 192, 168, 1, 33 };<br><br>#define PREFIX &quot;/nemarc&quot; // This will be appended to the IP address as the URL<br>WebServer webserver(PREFIX, 80);<br><br>byte shield1BankA = 0; // Current status of all outputs on first shield, one bit per output<br>byte shield2BankA = 0; // Current status of all outputs on second shield, one bit per output<br><br>/* This command is set as the default command for the server. It<br> * handles both GET and POST requests. For a GET, it returns a simple<br> * page with some buttons. For a POST, it saves the value posted to<br> * the buzzDelay variable, affecting the output of the speaker */<br>void serverCmd(WebServer &amp;server, WebServer::ConnectionType type, char *url_tail, bool tail_complete)<br>{<br> /* If we've received a POST request we need to process the submitted form values */<br> if (type == WebServer::POST)<br> {<br> bool repeat;<br> char name[20], value[16];<br> do<br> {<br> /* readPOSTparam returns false when there are no more parameters<br> * to read from the input. We pass in buffers for it to store<br> * the name and value strings along with the length of those<br> * buffers. */<br> repeat = server.readPOSTparam( name, 20, value, 16);<br><br> /* This is a standard string comparison function. It returns 0<br> * when there's an exact match. */<br> if (strcmp( name, &quot;On&quot; ) == 0)<br> {<br> setLatchChannelOn( atoi(value) );<br> }<br> <br> if (strcmp( name, &quot;Off&quot; ) == 0)<br> {<br> setLatchChannelOff( atoi(value) );<br> }<br> <br> if (strcmp( name, &quot;AllOff&quot; ) == 0)<br> {<br> sendRawValueToLatch1(0);<br> sendRawValueToLatch2(0);<br> }<br> <br> } while (repeat); <br> <br> // After procesing the POST data, tell the web browser to reload<br> // the page using a GET method. <br> server.httpSeeOther(PREFIX);<br> return;<br> }<br><br> /* for a GET or HEAD, send the standard &quot;it's all OK&quot; headers */<br> server.httpSuccess();<br><br> /* Don't output the body for a HEAD request, only for GET */<br> if (type == WebServer::GET)<br> {<br> /* store the HTML in program memory using the P macro */<br> P(message) = <br> &quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;N.E.M.A.R.C.&lt;/title&gt;&quot;<br> &quot;&lt;body&gt;&quot;<br> &quot;&lt;H1 style=font-family:hobo std&gt; N.E.M.A.R.C. &lt;/H1&gt;&quot;<br><br>// this is where I am want my temp/hum, but nothing seems to work..</p><p>// I tried putting the style attributes in the head and that didn't take either...?<br><br> <br> &quot;&lt;form action='/nemarc' method='POST'&gt;&quot;<br> <br> &quot;&lt;p&gt;&lt;button name='AllOff' value='0'&gt;All Off&lt;/button&gt;&lt;/p&gt;&quot;<br> <br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='1'&gt;1 On&lt;/button&gt;&lt;button type='submit' name='Off' value='1'&gt;1 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='2'&gt;2 On&lt;/button&gt;&lt;button type='submit' name='Off' value='2'&gt;2 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='3'&gt;3 On&lt;/button&gt;&lt;button type='submit' name='Off' value='3'&gt;3 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='4'&gt;4 On&lt;/button&gt;&lt;button type='submit' name='Off' value='4'&gt;4 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='5'&gt;5 On&lt;/button&gt;&lt;button type='submit' name='Off' value='5'&gt;5 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='6'&gt;6 On&lt;/button&gt;&lt;button type='submit' name='Off' value='6'&gt;6 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='7'&gt;7 On&lt;/button&gt;&lt;button type='submit' name='Off' value='7'&gt;7 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='8'&gt;8 On&lt;/button&gt;&lt;button type='submit' name='Off' value='8'&gt;8 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> <br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='9'&gt;9 On&lt;/button&gt;&lt;button type='submit' name='Off' value='9'&gt;9 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='10'&gt;10 On&lt;/button&gt;&lt;button type='submit' name='Off' value='10'&gt;10 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='11'&gt;11 On&lt;/button&gt;&lt;button type='submit' name='Off' value='11'&gt;11 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='12'&gt;12 On&lt;/button&gt;&lt;button type='submit' name='Off' value='12'&gt;12 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='13'&gt;13 On&lt;/button&gt;&lt;button type='submit' name='Off' value='13'&gt;13 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='14'&gt;14 On&lt;/button&gt;&lt;button type='submit' name='Off' value='14'&gt;14 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='15'&gt;15 On&lt;/button&gt;&lt;button type='submit' name='Off' value='15'&gt;15 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> &quot;&lt;p&gt;&lt;button type='submit' name='On' value='16'&gt;16 On&lt;/button&gt;&lt;button type='submit' name='Off' value='16'&gt;16 Off&lt;/button&gt;&lt;/p&gt;&quot;<br> <br> &quot;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;&quot;;<br><br> server.printP(message);<br> }<br>}<br><br>/**<br> */<br>void setup()<br>{<br> Wire.begin(); // Wake up I2C bus<br> Serial.begin( 38400 );<br> Serial.println(&quot;N.E.M.A.R.C.&quot;);<br> <br> Serial.print(&quot;Getting MAC address from ROM: &quot;);<br> mac[0] = readRegister(0xFA);<br> mac[1] = readRegister(0xFB);<br> mac[2] = readRegister(0xFC);<br> mac[3] = readRegister(0xFD);<br> mac[4] = readRegister(0xFE);<br> mac[5] = readRegister(0xFF);<br> char tmpBuf[17];<br> sprintf(tmpBuf, &quot;%02X:%02X:%02X:%02X:%02X:%02X&quot;, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);<br> Serial.println(tmpBuf);<br> <br> // setup the Ethernet library to talk to the Wiznet board<br> Ethernet.begin(mac, ip); // Use static address defined above<br> //Ethernet.begin(mac); // Use DHCP<br> <br> // Print IP address:<br> Serial.print(&quot;My URL: http://&quot;);<br> for (byte thisByte = 0; thisByte &lt; 4; thisByte++) {<br> // print the value of each byte of the IP address:<br> Serial.print(Ethernet.localIP()[thisByte], DEC);<br> if( thisByte &lt; 3 )<br> {<br> Serial.print(&quot;.&quot;);<br> }<br> }<br> Serial.println(&quot;/nemarc&quot;);<br><br> /* Register the default command (activated with the request of<br> * <a href="http://x.x.x.x/nemarc" rel="nofollow"> http://x.x.x.x/nemarc </a> */<br> webserver.setDefaultCommand(&amp;serverCmd);<br><br> /* start the server to wait for connections */<br> webserver.begin();<br><br> /* Set up the Relay8 shields */<br> initialiseShield(SHIELD_1_I2C_ADDRESS);<br> sendRawValueToLatch1(0); // If we don't do this, channel 6 turns on! I don't know why<br> <br> initialiseShield(SHIELD_2_I2C_ADDRESS);<br> sendRawValueToLatch2(0); // If we don't do this, channel 6 turns on! I don't know why<br> <br> Serial.println(&quot;Ready.&quot;);<br><br> dht.begin();<br>}<br><br>/**<br> */<br>void loop()<br>{<br> // Process incoming connections one at a time forever<br> webserver.processConnection();<br><br> <br> // Reading temperature or humidity takes about 250 milliseconds!<br> // Sensor readings may also be up to 2 seconds 'old'<br> float h = dht.readHumidity();<br> float t = dht.readTemperature();<br><br> // check if returns are valid, if they are NaN (not a number) then something went wrong!<br><br> if (isnan(t) || isnan(h)) {<br> Serial.println(&quot;Failed to read from DHT&quot;);<br> } else {<br> Serial.print(&quot;Humidity: &quot;);<br> Serial.print(h);<br> Serial.print(&quot; %\t&quot;);<br> Serial.print(&quot;Temperature: &quot;);<br> Serial.print(t);<br> Serial.println(&quot; *C&quot;);<br> delay(500);<br> }<br><br>}<br><br>/**<br> */<br>void initialiseShield(int shieldAddress)<br>{<br> // Set addressing style<br> Wire.beginTransmission(shieldAddress);<br> Wire.write(0x12);<br> Wire.write(0x20); // use table 1.4 addressing<br> Wire.endTransmission();<br><br> // Set I/O bank A to outputs<br> Wire.beginTransmission(shieldAddress);<br> Wire.write(0x00); // IODIRA register<br> Wire.write(0x00); // Set all of bank A to outputs<br> Wire.endTransmission();<br>}<br><br>/**<br> */<br>void toggleLatchChannel(byte channelId)<br>{<br> if( channelId &gt;= 1 &amp;&amp; channelId &lt;= 8 )<br> {<br> byte shieldOutput = channelId;<br> byte channelMask = 1 &lt;&lt; (shieldOutput - 1);<br> shield1BankA = shield1BankA ^ channelMask;<br> sendRawValueToLatch1(shield1BankA);<br> }<br> else if( channelId &gt;= 9 &amp;&amp; channelId &lt;= 16 )<br> {<br> byte shieldOutput = channelId - 8;<br> byte channelMask = 1 &lt;&lt; (shieldOutput - 1);<br> shield2BankA = shield2BankA ^ channelMask;<br> sendRawValueToLatch2(shield2BankA);<br> }<br>}<br><br>/**<br> */<br>void setLatchChannelOn (byte channelId)<br>{<br> if( channelId &gt;= 1 &amp;&amp; channelId &lt;= 8 )<br> {<br> byte shieldOutput = channelId;<br> byte channelMask = 1 &lt;&lt; (shieldOutput - 1);<br> shield1BankA = shield1BankA | channelMask;<br> sendRawValueToLatch1(shield1BankA);<br> }<br> else if( channelId &gt;= 9 &amp;&amp; channelId &lt;= 16 )<br> {<br> byte shieldOutput = channelId - 8;<br> byte channelMask = 1 &lt;&lt; (shieldOutput - 1);<br> shield2BankA = shield2BankA | channelMask;<br> sendRawValueToLatch2(shield2BankA);<br> }<br>}<br><br><br>/**<br> */<br>void setLatchChannelOff (byte channelId)<br>{<br> if( channelId &gt;= 1 &amp;&amp; channelId &lt;= 8 )<br> {<br> byte shieldOutput = channelId;<br> byte channelMask = 255 - ( 1 &lt;&lt; (shieldOutput - 1));<br> shield1BankA = shield1BankA &amp; channelMask;<br> sendRawValueToLatch1(shield1BankA);<br> }<br> else if( channelId &gt;= 9 &amp;&amp; channelId &lt;= 16 )<br> {<br> byte shieldOutput = channelId - 8;<br> byte channelMask = 255 - ( 1 &lt;&lt; (shieldOutput - 1));<br> shield2BankA = shield2BankA &amp; channelMask;<br> sendRawValueToLatch2(shield2BankA);<br> }<br>}<br><br>/**<br> */<br>void sendRawValueToLatch1(byte rawValue)<br>{<br> Wire.beginTransmission(SHIELD_1_I2C_ADDRESS);<br> Wire.write(0x12); // Select GPIOA<br> Wire.write(rawValue); // Send value to bank A<br> shield1BankA = rawValue;<br> Wire.endTransmission();<br>}<br><br>/**<br> */<br>void sendRawValueToLatch2(byte rawValue)<br>{<br> Wire.beginTransmission(SHIELD_2_I2C_ADDRESS);<br> Wire.write(0x12); // Select GPIOA<br> Wire.write(rawValue); // Send value to bank A<br> shield2BankA = rawValue;<br> Wire.endTransmission();<br>}<br><br>/**<br> * Required to read the MAC address ROM<br> */<br>byte readRegister(byte r)<br>{<br> unsigned char v;<br> Wire.beginTransmission(MAC_I2C_ADDRESS);<br> Wire.write(r); // Register to read<br> Wire.endTransmission();<br><br> Wire.requestFrom(MAC_I2C_ADDRESS, 1); // Read a byte<br> while(!Wire.available())<br> {<br> // Wait<br> }<br> v = Wire.read();<br> return v;<br>}</p><p>Thank you for any help. </p>
<p>I made it ! It works perfectly! Thank you for your project.</p>
<p>I wish you had only one button for each sector. this button turns on and off , how do I fix this sketch ? I liked very please help</p>
I have &agrave; question About controling the relay 's also with &agrave; push button. I have read the part thats Bin post About the push buttons but i can not make it work. I want to use it on &agrave; dashboard so i can control the relay by web but when i'm in i can use the push buttons.<br><br>Ps: i want to tank al the people who work on the project !!
<strong>Can someone please help me with this i can not make it work :(</strong><p><strong>here 's my code:</strong></p><p>/////////////////////////////////////////////////////////////////////////////////////////////////////////</p><p>#include &lt;String.h&gt; // used for login</p><p>#include &lt;Ethernet.h&gt;</p><p>#include &lt;SPI.h&gt;</p><p>#include &lt;EEPROM.h&gt;</p><p>////////////////////////////////////////////////////////////////////////</p><p>//CONFIGURATION</p><p>////////////////////////////////////////////////////////////////////////</p><p>//IP manual settings</p><p>byte ip[] = {10, 134, 36, 6 }; //Manual setup only</p><p>byte gateway[] = {10, 134, 36, 1 }; //Manual setup only</p><p>byte subnet[] = {255, 255, 255, 0 }; //Manual setup only</p><p>// if need to change the MAC address (Very Rare)</p><p>byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};</p><p>//Ethernet Port</p><p>EthernetServer server = EthernetServer(80); //default html port 80</p><p>//The number of outputs going to be switched.</p><p>int outputQuantity = 16; //should not exceed 10</p><p>//Invert the output of the leds</p><p>boolean outputInverted = false; //true or false</p><p>// This is done in case the relay board triggers the relay on negative, rather then on positive supply</p><p>//Html page refresh</p><p>int refreshPage = 15; //default is 10sec.</p><p>//Beware that if you make it refresh too fast, the page could become inacessable.</p><p>//Display or hide the &quot;Switch on all Pins&quot; buttons at the bottom of page</p><p>int switchOnAllPinsButton = false; //true or false</p><p>// Select the pinout address</p><p>int outputAddress[] = {22, //Allocate 10 spaces and name the output pin address.</p><p> 23,</p><p> 24,</p><p> 25,</p><p> 26,</p><p> 27,</p><p> 28,</p><p> 29,</p><p> 30,</p><p> 31,</p><p> 32,</p><p> 33,</p><p> 34,</p><p> 35,</p><p> 36,</p><p> 37}; </p><p>//PS pin addresses 10, 11, 12 and 13 on the Duemilanove are used for the ethernet shield, therefore cannot be used.</p><p>//PS pin addresses 10, 50, 51 and 52 and 53 on the Mega are used for the ethernet shield, therefore cannot be used.</p><p>//PS pin addresses 4, are used for the SD card, therefore cannot be used.</p><p>//PS pin address 2 is used for interrupt-driven notification, therefore could not be used.</p><p>// Write the text description of the output channel</p><p>String buttonText[16] = {&quot;01. Top licht&quot;,</p><p> &quot;02. Board verlichting&quot;,</p><p> &quot;03. Anker licht&quot;,</p><p> &quot;04. Motor afzuiging&quot;,</p><p> &quot;05. Binnen verlichting&quot;,</p><p> &quot;06. Water pomp&quot;,</p><p> &quot;07. Omvormer&quot;,</p><p> &quot;08. Dieseltank meter&quot;,</p><p> &quot;09. Dashboard verlichting&quot;,</p><p> &quot;10. USB Lader Binnen&quot;,</p><p> &quot;11. USB Lader buiten&quot;,</p><p> &quot;12. Kajuit verlichting&quot;,</p><p> &quot;13. Waterlank meter&quot;,</p><p> &quot;14. Toeter&quot;,</p><p> &quot;15. Auto radio&quot;,</p><p> &quot;16. 27MC Bakkie&quot;};</p><p>// Set the output to retain the last status after power recycle.</p><p>int retainOutputStatus[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //1-retain the last status. 0-will be off after power cut.</p><p>////////////////////////////////////////////////////////////////////</p><p>// Controling relays with pusch buttons</p><p>////////////////////////////////////////////////////////////////////</p><p>// Relays</p><p>int Top_licht = 22;</p><p>int Board_verlichting = 23;</p><p>int Anker_licht = 24;</p><p>int Motor_afzuiging = 25;</p><p>int Binnen_verlichting = 26;</p><p>int Water_pomp = 27;</p><p>int Omvormer = 28;</p><p>int Dieseltank_meter = 29;</p><p>int Dashboard_verlichting = 30;</p><p>int USB_Lader_Binnen = 31;</p><p>int USB_Lader_buiten = 32;</p><p>int Kajuit_verlichting = 33;</p><p>int Waterlank_meter = 34;</p><p>int Toeter = 35;</p><p>int Auto_radio = 36;</p><p>int Bakkie = 37;</p><p>// Button Pins</p><p>int button1 = 38; // Top_licht</p><p>int button2 = 39; // Board_verlichting</p><p>int button3 = 40; // Anker_licht</p><p>int button4 = 41; // Motor_afzuiging</p><p>int button5 = 42; // Binnen_verlichting</p><p>int button6 = 43; // Water_pomp</p><p>int button7 = 44; // Omvormer</p><p>int button8 = 45; // Dieseltank_meter</p><p>int button9 = 46; // Dashboard_verlichting</p><p>int button10 = 47; // USB_Lader_Binnen</p><p>int button11 = 48; // USB_Lader_buiten</p><p>int button12 = 49; // Kajuit_verlichting</p><p>int button13 = 50; // Waterlank_meter</p><p>int button14 = 51; // Toeter</p><p>int button15 = 52; // Auto_radio</p><p>int button16 = 53; // Bakkie</p><p>// This remembers the buttons last state</p><p>boolean lastButton = LOW;</p><p>boolean currentButton = LOW;</p><p>boolean ledOn = false;</p><p>boolean lastButton2 = LOW;</p><p>boolean currentButton2 = LOW;</p><p>boolean ledOn2 = false;</p><p>boolean lastButton3 = LOW;</p><p>boolean currentButton3 = LOW;</p><p>boolean ledOn3 = false;</p><p>boolean lastButton4 = LOW;</p><p>boolean currentButton4 = LOW;</p><p>boolean ledOn4 = false;</p><p>boolean lastButton5 = LOW;</p><p>boolean currentButton5 = LOW;</p><p>boolean ledOn5 = false;</p><p>boolean lastButton6 = LOW;</p><p>boolean currentButton6 = LOW;</p><p>boolean ledOn6 = false;</p><p>boolean lastButton7 = LOW;</p><p>boolean currentButton7 = LOW;</p><p>boolean ledOn7 = false;</p><p>boolean lastButton8 = LOW;</p><p>boolean currentButton8 = LOW;</p><p>boolean ledOn8 = false;</p><p>boolean lastButton9 = LOW;</p><p>boolean currentButton9 = LOW;</p><p>boolean ledOn9 = false;</p><p>boolean lastButton10 = LOW;</p><p>boolean currentButton10 = LOW;</p><p>boolean ledOn10 = false;</p><p>boolean lastButton11 = LOW;</p><p>boolean currentButton11 = LOW;</p><p>boolean ledOn11 = false;</p><p>boolean lastButton12 = LOW;</p><p>boolean currentButton12 = LOW;</p><p>boolean ledOn12 = false;</p><p>boolean lastButton13 = LOW;</p><p>boolean currentButton13 = LOW;</p><p>boolean ledOn13 = false;</p><p>boolean lastButton14 = LOW;</p><p>boolean currentButton14 = LOW;</p><p>boolean ledOn14 = false;</p><p>boolean lastButton15 = LOW;</p><p>boolean currentButton15 = LOW;</p><p>boolean ledOn15 = false;</p><p>boolean lastButton16 = LOW;</p><p>boolean currentButton16 = LOW;</p><p>boolean ledOn16 = false;</p><p>////////////////////////////////////////////////////////////////////////</p><p>//pusch buttons end</p><p>////////////////////////////////////////////////////////////////////////</p><p>////////////////////////////////////////////////////////////////////////</p><p>//VARIABLES DECLARATION</p><p>////////////////////////////////////////////////////////////////////////</p><p>int outp = 0;</p><p>boolean printLastCommandOnce = false;</p><p>boolean printButtonMenuOnce = false;</p><p>boolean initialPrint = true;</p><p>String allOn = &quot;&quot;;</p><p>String allOff = &quot;&quot;;</p><p>boolean reading = false;</p><p>boolean outputStatus[16]; //Create a boolean array for the maximum ammount.</p><p>String rev = &quot;V6.01&quot;;</p><p>unsigned long timeConnectedAt;</p><p>boolean writeToEeprom = false;</p><p>String readString; //login</p><p>boolean login=false; //login</p><p>/////////////////////////////////////////////////</p><p>// Temperature Related Reading</p><p>/////////////////////////////////////////////////</p><p>const int tempInPin = A1;</p><p>int tempInValue = 0; //temperature read</p><p>int tempScaleOutValue = 0; //temperature formatted</p><p>int tempOutValue = 0; //temperature formatted</p><p>float tempOutDeg = 0.0;</p><p>////////////////////////////////////////////////////////////////////////</p><p>//RUN ONCE</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Beginning of Program</p><p>void setup(){</p><p> Serial.begin(9600);</p><p> initEepromValues();</p><p> readEepromValues();</p><p> //Set pins as Outputs</p><p> boolean currentState = false;</p><p> int var;</p><p> for (int i = 0; i &lt; outputQuantity; i++){</p><p> pinMode(outputAddress[i], OUTPUT);</p><p> var = outputAddress[i];</p><p> //Switch all outputs to either on or off on Startup</p><p> if(outputInverted == true) {</p><p> //digitalWrite(outputAddress[var], HIGH);</p><p> if(outputStatus[i] == 0){currentState = true;}else{currentState = false;} //check outputStatus if off, switch output accordingly</p><p> digitalWrite(var, currentState);</p><p> }</p><p> else{</p><p> //digitalWrite(outputAddress[var], LOW);</p><p> if(outputStatus[i] == 0){currentState = false;}else{currentState = true;} //check outputStatus if off, switch output accordingly</p><p> digitalWrite(var, currentState);</p><p> }</p><p> }</p><p> //Setting up the IP address. Comment out the one you dont need.</p><p> //Ethernet.begin(mac); //for DHCP address. (Address will be printed to serial.)</p><p> Ethernet.begin(mac, ip, gateway, subnet); //for manual setup. (Address is the one configured above.)</p><p> server.begin();</p><p> Serial.print(&quot;Server started at &quot;);</p><p> Serial.println(Ethernet.localIP());</p><p>////////////////////////////////////////////////////////////////////</p><p>// Controling relays with pusch buttons</p><p>////////////////////////////////////////////////////////////////////</p><p>// These are the relays conected to the lights</p><p>{</p><p>pinMode(Top_licht, OUTPUT); //pin selected to control22;</p><p>pinMode(Board_verlichting, OUTPUT); //pin selected to control23;</p><p>pinMode(Anker_licht, OUTPUT); //pin selected to control24;</p><p>pinMode(Motor_afzuiging, OUTPUT); //pin selected to control25;</p><p>pinMode(Binnen_verlichting, OUTPUT); //pin selected to control26;</p><p>pinMode(Water_pomp, OUTPUT); //pin selected to control27;</p><p>pinMode(Omvormer, OUTPUT); //pin selected to control28;</p><p>pinMode(Dieseltank_meter, OUTPUT); //pin selected to control29;</p><p>pinMode(Dashboard_verlichting, OUTPUT); //pin selected to control30;</p><p>pinMode(USB_Lader_Binnen, OUTPUT); //pin selected to control31;</p><p>pinMode(USB_Lader_buiten, OUTPUT); //pin selected to control32;</p><p>pinMode(Kajuit_verlichting, OUTPUT); //pin selected to control33;</p><p>pinMode(Waterlank_meter, OUTPUT); //pin selected to control34;</p><p>pinMode(Toeter, OUTPUT); //pin selected to control35;</p><p>pinMode(Auto_radio, OUTPUT); //pin selected to control36;</p><p>pinMode(Bakkie, OUTPUT); //pin selected to control37;</p><p>// These are the puch buttons the switch the lights on or off</p><p>pinMode(button1, INPUT);</p><p>pinMode(button2, INPUT);</p><p>pinMode(button3, INPUT);</p><p>pinMode(button4, INPUT);</p><p>pinMode(button5, INPUT);</p><p>pinMode(button6, INPUT);</p><p>pinMode(button7, INPUT);</p><p>pinMode(button8, INPUT);</p><p>pinMode(button9, INPUT);</p><p>pinMode(button10, INPUT);</p><p>pinMode(button11, INPUT);</p><p>pinMode(button12, INPUT);</p><p>pinMode(button13, INPUT);</p><p>pinMode(button14, INPUT);</p><p>pinMode(button15, INPUT);</p><p>pinMode(button16, INPUT);</p><p>}</p><p>}</p><p>// This part Debounces the buttons</p><p>// Button1 debounce</p><p>boolean debounce(boolean last)</p><p>{</p><p>boolean current = digitalRead(button1);</p><p>if (last != current)</p><p>{</p><p>delay(5);</p><p>current = digitalRead(button1);</p><p>}</p><p>return current;</p><p>}</p><p>// Button2 debounce</p><p>boolean debounce2(boolean last2)</p><p>{</p><p>boolean current2 = digitalRead(button2);</p><p>if (last2 != current2)</p><p>{</p><p>delay(5);</p><p>current2 = digitalRead(button2);</p><p>}</p><p>return current2;</p><p>}</p><p>// Button3 debounce</p><p>boolean debounce3(boolean last3)</p><p>{</p><p>boolean current3 = digitalRead(button3);</p><p>if (last3 != current3)</p><p>{</p><p>delay(5);</p><p>current3 = digitalRead(button3);</p><p>}</p><p>return current3;</p><p>}</p><p>// Button4 debounce</p><p>boolean debounce4(boolean last4)</p><p>{</p><p>boolean current4 = digitalRead(button4);</p><p>if (last4 != current4)</p><p>{</p><p>delay(5);</p><p>current4 = digitalRead(button4);</p><p>}</p><p>return current4;</p><p>}</p><p>// Button5 debounce</p><p>boolean debounce5(boolean last5)</p><p>{</p><p>boolean current5 = digitalRead(button5);</p><p>if (last5 != current5)</p><p>{</p><p>delay(5);</p><p>current5 = digitalRead(button5);</p><p>}</p><p>return current5;</p><p>}</p><p>// Button6 debounce</p><p>boolean debounce6(boolean last6)</p><p>{</p><p>boolean current6 = digitalRead(button6);</p><p>if (last6 != current6)</p><p>{</p><p>delay(5);</p><p>current6 = digitalRead(button6);</p><p>}</p><p>return current6;</p><p>}</p><p>// Button7 debounce</p><p>boolean debounce7(boolean last7)</p><p>{</p><p>boolean current7 = digitalRead(button7);</p><p>if (last7 != current7)</p><p>{</p><p>delay(5);</p><p>current7 = digitalRead(button7);</p><p>}</p><p>return current7;</p><p>}</p><p>// Button8 debounce</p><p>boolean debounce8(boolean last8)</p><p>{</p><p>boolean current8 = digitalRead(button8);</p><p>if (last8 != current8)</p><p>{</p><p>delay(5);</p><p>current8 = digitalRead(button8);</p><p>}</p><p>return current8;</p><p>}</p><p>// Button9 debounce</p><p>boolean debounce9(boolean last9)</p><p>{</p><p>boolean current9 = digitalRead(button9);</p><p>if (last9 != current9)</p><p>{</p><p>delay(5);</p><p>current9 = digitalRead(button9);</p><p>}</p><p>return current9;</p><p>}</p><p>// Button10 debounce</p><p>boolean debounce10(boolean last10)</p><p>{</p><p>boolean current10 = digitalRead(button10);</p><p>if (last10 != current10)</p><p>{</p><p>delay(5);</p><p>current10 = digitalRead(button10);</p><p>}</p><p>return current10;</p><p>}</p><p>// Button11 debounce</p><p>boolean debounce11(boolean last11)</p><p>{</p><p>boolean current11 = digitalRead(button11);</p><p>if (last11 != current11)</p><p>{</p><p>delay(5);</p><p>current11 = digitalRead(button11);</p><p>}</p><p>return current11;</p><p>}</p><p>// Button12 debounce</p><p>boolean debounce12(boolean last12)</p><p>{</p><p>boolean current12 = digitalRead(button12);</p><p>if (last12 != current12)</p><p>{</p><p>delay(5);</p><p>current12 = digitalRead(button12);</p><p>}</p><p>return current12;</p><p>}</p><p>// Button13 debounce</p><p>boolean debounce13(boolean last13)</p><p>{</p><p>boolean current13 = digitalRead(button13);</p><p>if (last13 != current13)</p><p>{</p><p>delay(5);</p><p>current13 = digitalRead(button13);</p><p>}</p><p>return current13;</p><p>}</p><p>// Button14 debounce</p><p>boolean debounce14(boolean last14)</p><p>{</p><p>boolean current14 = digitalRead(button14);</p><p>if (last14 != current14)</p><p>{</p><p>delay(5);</p><p>current14 = digitalRead(button14);</p><p>}</p><p>return current14;</p><p>}</p><p>// Button15 debounce</p><p>boolean debounce15(boolean last15)</p><p>{</p><p>boolean current15 = digitalRead(button15);</p><p>if (last15 != current15)</p><p>{</p><p>delay(5);</p><p>current15 = digitalRead(button15);</p><p>}</p><p>return current15;</p><p>}</p><p>// Button16 debounce</p><p>boolean debounce16(boolean last16)</p><p>{</p><p>boolean current16 = digitalRead(button16);</p><p>if (last16 != current16)</p><p>{</p><p>delay(5);</p><p>current16 = digitalRead(button16);</p><p>}</p><p>return current16;</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//pusch buttons end</p><p>////////////////////////////////////////////////////////////////////////</p><p>////////////////////////////////////////////////////////////////////////</p><p>//LOOP</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Run once</p><p>void loop(){</p><p> //Read Temperature Sensor</p><p> tempInValue = analogRead(tempInPin);</p><p> // Connecting a 10K3 Thermistor to the Arduino Input</p><p> // +5V �&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;[10Kohms]&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;[Thermistor]&mdash;&mdash;� 0V</p><p> // To Arduino IP �&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;|</p><p> tempScaleOutValue = map(tempInValue, 0, 1023, 1023, 0); //Arduino value and NTC of the 10K3 Thermistor</p><p> tempOutValue = map(tempScaleOutValue, 130, 870, -170, 730); //range of Arduino Value compared with Temperature</p><p> tempOutValue = tempOutValue -45; //Adjustments</p><p> tempOutDeg = tempOutValue / 10.0;</p><p>////////////////////////////////////////////////////////////////////</p><p>// Controling relays with pusch buttons</p><p>////////////////////////////////////////////////////////////////////</p><p>// And here is where the magic is done</p><p>// Start buttons</p><p>//button1 --------------------------------------------------------</p><p>currentButton = debounce(lastButton);</p><p>if (lastButton == LOW &amp;&amp; currentButton == HIGH)</p><p>{</p><p>ledOn = !ledOn;</p><p>}</p><p>lastButton = currentButton;</p><p>digitalWrite(Top_licht, ledOn);</p><p>currentButton = debounce(lastButton);</p><p>if (lastButton == LOW &amp;&amp; currentButton == HIGH)</p><p>{</p><p>ledOn = !ledOn;</p><p>}</p><p>lastButton = currentButton;</p><p>digitalWrite(Top_licht, ledOn);</p><p>//button2 --------------------------------------------------------</p><p>currentButton2 = debounce2(lastButton2);</p><p>if (lastButton2 == LOW &amp;&amp; currentButton2 == HIGH)</p><p>{</p><p>ledOn2 = !ledOn2;</p><p>}</p><p>lastButton2 = currentButton2;</p><p>digitalWrite(Board_verlichting, ledOn2);</p><p>//button3 --------------------------------------------------------</p><p>currentButton3 = debounce3(lastButton3);</p><p>if (lastButton3 == LOW &amp;&amp; currentButton3 == HIGH)</p><p>{</p><p>ledOn3 = !ledOn3;</p><p>}</p><p>lastButton3 = currentButton3;</p><p>digitalWrite(Anker_licht, ledOn3);</p><p>//button4 --------------------------------------------------------</p><p>currentButton4 = debounce4(lastButton4);</p><p>if (lastButton4 == LOW &amp;&amp; currentButton4 == HIGH)</p><p>{</p><p>ledOn4 = !ledOn4;</p><p>}</p><p>lastButton4 = currentButton4;</p><p>digitalWrite(Motor_afzuiging, ledOn4);</p><p>//button5 --------------------------------------------------------</p><p>currentButton5 = debounce5(lastButton5);</p><p>if (lastButton5 == LOW &amp;&amp; currentButton5 == HIGH)</p><p>{</p><p>ledOn5 = !ledOn5;</p><p>}</p><p>lastButton5 = currentButton5;</p><p>digitalWrite(Top_licht, ledOn5);</p><p>//button6 --------------------------------------------------------</p><p>currentButton6 = debounce6(lastButton6);</p><p>if (lastButton6 == LOW &amp;&amp; currentButton6 == HIGH)</p><p>{</p><p>ledOn6 = !ledOn6;</p><p>}</p><p>lastButton6 = currentButton6;</p><p>digitalWrite(Board_verlichting, ledOn6);</p><p>//button7 --------------------------------------------------------</p><p>currentButton7 = debounce7(lastButton7);</p><p>if (lastButton7 == LOW &amp;&amp; currentButton7 == HIGH)</p><p>{</p><p>ledOn7 = !ledOn7;</p><p>}</p><p>lastButton7 = currentButton7;</p><p>digitalWrite(Anker_licht, ledOn7);</p><p>//button8 --------------------------------------------------------</p><p>currentButton8 = debounce8(lastButton8);</p><p>if (lastButton8 == LOW &amp;&amp; currentButton8 == HIGH)</p><p>{</p><p>ledOn8 = !ledOn8;</p><p>}</p><p>lastButton8 = currentButton8;</p><p>digitalWrite(Motor_afzuiging, ledOn8);</p><p>//button9 --------------------------------------------------------</p><p>currentButton9 = debounce9(lastButton9);</p><p>if (lastButton9 == LOW &amp;&amp; currentButton9 == HIGH)</p><p>{</p><p>ledOn9 = !ledOn9;</p><p>}</p><p>lastButton9 = currentButton9;</p><p>digitalWrite(Top_licht, ledOn9);</p><p>//button10 --------------------------------------------------------</p><p>currentButton10 = debounce10(lastButton10);</p><p>if (lastButton10 == LOW &amp;&amp; currentButton10 == HIGH)</p><p>{</p><p>ledOn10 = !ledOn10;</p><p>}</p><p>lastButton10 = currentButton10;</p><p>digitalWrite(Board_verlichting, ledOn10);</p><p>//button11 --------------------------------------------------------</p><p>currentButton11 = debounce11(lastButton11);</p><p>if (lastButton11 == LOW &amp;&amp; currentButton11 == HIGH)</p><p>{</p><p>ledOn11 = !ledOn11;</p><p>}</p><p>lastButton11 = currentButton11;</p><p>digitalWrite(Anker_licht, ledOn11);</p><p>//button12 --------------------------------------------------------</p><p>currentButton12 = debounce12(lastButton12);</p><p>if (lastButton12 == LOW &amp;&amp; currentButton12 == HIGH)</p><p>{</p><p>ledOn12 = !ledOn12;</p><p>}</p><p>lastButton12 = currentButton12;</p><p>digitalWrite(Motor_afzuiging, ledOn12);</p><p>//button13 --------------------------------------------------------</p><p>currentButton13 = debounce13(lastButton13);</p><p>if (lastButton13 == LOW &amp;&amp; currentButton13 == HIGH)</p><p>{</p><p>ledOn13 = !ledOn13;</p><p>}</p><p>lastButton13 = currentButton13;</p><p>digitalWrite(Top_licht, ledOn13);</p><p>//button14 --------------------------------------------------------</p><p>currentButton14 = debounce10(lastButton14);</p><p>if (lastButton14 == LOW &amp;&amp; currentButton14 == HIGH)</p><p>{</p><p>ledOn14 = !ledOn14;</p><p>}</p><p>lastButton14 = currentButton14;</p><p>digitalWrite(Board_verlichting, ledOn14);</p><p>//button15 --------------------------------------------------------</p><p>currentButton15 = debounce15(lastButton15);</p><p>if (lastButton15 == LOW &amp;&amp; currentButton15 == HIGH)</p><p>{</p><p>ledOn15 = !ledOn15;</p><p>}</p><p>lastButton15 = currentButton15;</p><p>digitalWrite(Anker_licht, ledOn15);</p><p>//button16 --------------------------------------------------------</p><p>currentButton16 = debounce16(lastButton16);</p><p>if (lastButton16 == LOW &amp;&amp; currentButton16 == HIGH)</p><p>{</p><p>ledOn16 = !ledOn16;</p><p>}</p><p>lastButton16 = currentButton16;</p><p>digitalWrite(Motor_afzuiging, ledOn16);</p><p>////////////////////////////////////////////////////////////////////////</p><p>//pusch buttons end</p><p>////////////////////////////////////////////////////////////////////////</p><p> // listen for incoming clients, and process requests.</p><p> checkForClient();</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//checkForClient Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>void checkForClient(){</p><p> EthernetClient client = server.available();</p><p> if (client) {</p><p> // an http request ends with a blank line</p><p> boolean currentLineIsBlank = true;</p><p> boolean sentHeader = false;</p><p> int temp,temp1;</p><p> while (client.connected()) {</p><p> if (client.available()) {</p><p> //if header was not set send it</p><p> //read user input</p><p> char c = client.read();</p><p> Serial.println(c); //login</p><p> readString.concat(c); //login</p><p> if(c == '*'){</p><p> printHtmlHeader(client); //call for html header and css</p><p> printLoginTitle(client);</p><p> printHtmlFooter(client);</p><p> //sentHeader = true;</p><p> login=false; //login </p><p> break;</p><p> }</p><p> if(!sentHeader){</p><p> printHtmlHeader(client); //call for html header and css</p><p> printHtmlButtonTitle(client); //print the button title</p><p> //This is for the arduino to construct the page on the fly. </p><p> sentHeader = true;</p><p> }</p><p> //if there was reading but is blank there was no reading </p><p> if(reading &amp;&amp; c == ' '){</p><p> reading = false;</p><p> login=false;</p><p> }</p><p> //if there is a ? there was user input</p><p> if(c == '?') {</p><p> reading = true; //found the ?, begin reading the info</p><p> }</p><p> //login if added</p><p> if (login==false) {</p><p> if(readString.indexOf(&quot;User=1&amp;Pass=1&quot;) &gt; 0) { //repalce yourusername and yourpassword with your values</p><p> login=true;</p><p> }</p><p> }</p><p> // if there was user input switch the relevant output</p><p> //login &amp;&amp; added</p><p> if(login &amp;&amp; reading){</p><p> //if user input is H set output to 1</p><p> if(c == 'H') {</p><p> outp = 1;</p><p> }</p><p> //if user input is L set output to 0</p><p> if(c == 'L') {</p><p> outp = 0;</p><p> }</p><p>// Serial.println(c); //print the value of c to serial communication</p><p>//--------------------------------------------------------------//</p><p>// ? H 1 0 //</p><p>// ^ ^ ^ ^ //</p><p>// | | | |____________read 4 ( 10,11,12,13....) //</p><p>// | | |______________read 3 ( 1....9) //</p><p>// | |________________read 2 if user input is H set output to L //</p><p>// |__________________read 1 //</p><p>//--------------------------------------------------------------//</p><p> if( c == '1'){</p><p> char c = client.read();</p><p> switch (c) {</p><p> case '0':</p><p> //add code here to trigger on 0</p><p> triggerPin(outputAddress[10], client, outp);</p><p> break; </p><p> case '1':</p><p> //add code here to trigger on 1</p><p> triggerPin(outputAddress[11], client, outp);</p><p> break; </p><p> case '2':</p><p> //add code here to trigger on 2</p><p> triggerPin(outputAddress[12], client, outp);</p><p> break;</p><p> case '3':</p><p> //add code here to trigger on 3</p><p> triggerPin(outputAddress[13], client, outp);</p><p> break;</p><p> case '4':</p><p> //add code here to trigger on 4</p><p> triggerPin(outputAddress[14], client, outp);</p><p> break;</p><p> case '5':</p><p> //add code here to trigger on 5</p><p> triggerPin(outputAddress[15], client, outp);</p><p> //printHtml(client);</p><p> break;</p><p> default:</p><p> char c = client.read();</p><p> triggerPin(outputAddress[1], client, outp);</p><p> }</p><p> }</p><p> else {</p><p> switch (c) {</p><p> case '0':</p><p> //add code here to trigger on 0</p><p> triggerPin(outputAddress[0], client, outp);</p><p> break; </p><p> //case '1':</p><p> //add code here to trigger on 1</p><p> //triggerPin(outputAddress[1], client, outp);</p><p> //break; </p><p> case '2':</p><p> //add code here to trigger on 2</p><p> triggerPin(outputAddress[2], client, outp);</p><p> break;</p><p> case '3':</p><p> //add code here to trigger on 3</p><p> triggerPin(outputAddress[3], client, outp);</p><p> break;</p><p> case '4':</p><p> //add code here to trigger on 4</p><p> triggerPin(outputAddress[4], client, outp);</p><p> break;</p><p> case '5':</p><p> //add code here to trigger on 5</p><p> triggerPin(outputAddress[5], client, outp);</p><p> //printHtml(client);</p><p> break;</p><p> case '6':</p><p> //add code here to trigger on 6</p><p> triggerPin(outputAddress[6], client, outp);</p><p> break;</p><p> case '7':</p><p> //add code here to trigger on 7</p><p> triggerPin(outputAddress[7], client, outp);</p><p> break;</p><p> case '8':</p><p> //add code here to trigger on 8</p><p> triggerPin(outputAddress[8], client, outp);</p><p> break;</p><p> case '9':</p><p> //add code here to trigger on 9</p><p> triggerPin(outputAddress[9], client, outp);</p><p> break;</p><p> case 'Logout':</p><p> login=false;</p><p> readString=&quot;&quot;;</p><p> } //end of switch case</p><p> }</p><p> }//end of switch switch the relevant output</p><p> //if user input was blank</p><p> if (c == '\n' &amp;&amp; currentLineIsBlank){</p><p> //login if added </p><p> if(login == false)</p><p> {</p><p> printLoginTitle(client);</p><p> printHtmlFooter(client);</p><p> readString=&quot;&quot;;</p><p> } </p><p> printLastCommandOnce = true;</p><p> printButtonMenuOnce = true;</p><p> triggerPin(777, client, outp); //Call to read input and print menu. 777 is used not to update any outputs</p><p> break;</p><p> } </p><p> }</p><p> }</p><p> printHtmlFooter(client); //Prints the html footer</p><p> } </p><p>else</p><p> { </p><p> //if there is no client</p><p> if (millis() &gt; (timeConnectedAt + 60000)){</p><p> if (writeToEeprom == true){</p><p> writeEepromValues(); //write to EEprom the current output statuses</p><p> Serial.println(&quot;No Clients for more then a minute - Writing statuses to Eeprom.&quot;);</p><p> writeToEeprom = false;</p><p> } </p><p> }</p><p> }</p><p>}</p><p>// END</p><p>////////////////////////////////////////////////////////////////////////</p><p>//triggerPin Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>void triggerPin(int pin, EthernetClient client, int outp){</p><p> //Switching on or off outputs, reads the outputs and prints the buttons</p><p> if (pin != 777){</p><p> // Serial.println(pin);</p><p> if(outp == 1) {</p><p> if (outputInverted ==false){</p><p> digitalWrite(pin, HIGH);</p><p> }</p><p> else{</p><p> digitalWrite(pin, LOW);</p><p> }</p><p> }</p><p> if(outp == 0){</p><p> if (outputInverted ==false){</p><p> digitalWrite(pin, LOW);</p><p> }</p><p> else{</p><p> digitalWrite(pin, HIGH);</p><p> }</p><p> }</p><p> }</p><p> //Refresh the reading of outputs</p><p> readOutputStatuses();</p><p> //Prints the buttons</p><p> if (printButtonMenuOnce == true){</p><p> printHtmlButtons(client);</p><p> printButtonMenuOnce = false;</p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//printHtmlButtons Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//print the html buttons to switch on/off channels</p><p>void printHtmlButtons(EthernetClient client){</p><p> //Start to create the html table</p><p> client.println(&quot;&quot;);</p><p> //client.println(&quot;&lt;p&gt;&quot;);</p><p> client.println(&quot;&lt;FORM&gt;&quot;);</p><p> client.println(&quot;&lt;table border=\&quot;0\&quot; align=\&quot;center\&quot;&gt;&quot;);</p><p> //Printing the Temperature</p><p> client.print(&quot;&lt;tr&gt;\n&quot;);</p><p> client.print(&quot;&lt;td&gt;&lt;h4&gt;&quot;);</p><p> client.print(&quot;Temperature&quot;);</p><p> client.print(&quot;&lt;/h4&gt;&lt;/td&gt;\n&quot;);</p><p> client.print(&quot;&lt;td&gt;&lt;/td&gt;&quot;);</p><p> client.print(&quot;&lt;td&gt;&quot;);</p><p> client.print(&quot;&lt;h3&gt;&quot;);</p><p> client.print(tempOutDeg);</p><p> client.print(&quot; &deg;C&lt;/h3&gt;&lt;/td&gt;\n&quot;);</p><p> client.print(&quot;&lt;td&gt;&lt;/td&gt;&quot;);</p><p> client.print(&quot;&lt;/tr&gt;&quot;);</p><p> //Start printing button by button</p><p> for (int var = 0; var &lt; outputQuantity; var++) {</p><p> //set command for all on/off</p><p> allOn += &quot;H&quot;;</p><p> allOn += outputAddress[var];</p><p> allOff += &quot;L&quot;;</p><p> allOff += outputAddress[var];</p><p> //Print begining of row</p><p> client.print(&quot;&lt;tr&gt;\n&quot;);</p><p> //Prints the button Text</p><p> client.print(&quot;&lt;td&gt;&lt;h4&gt;&quot;);</p><p> client.print(buttonText[var]);</p><p> client.print(&quot;&lt;/h4&gt;&lt;/td&gt;\n&quot;);</p><p> //Prints the ON Buttons+++++++++++++++++++++++++++++++++++++++++++++++</p><p> client.print(&quot;&lt;td&gt;&quot;);</p><p> client.print(&quot;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;ON &quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?H&quot;);</p><p> client.print(var);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&quot;);</p><p> //Prints the OFF Buttons ---------------------------------------------</p><p> client.print(&quot; &lt;td&gt;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;OFF&quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?L&quot;);</p><p> client.print(var);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&quot;);</p><p> //Invert the LED display if output is inverted.</p><p> if (outputStatus[var] == true ){ //If Output is ON</p><p> if (outputInverted == false){ //and if output is not inverted</p><p> client.print(&quot; &lt;td&gt;&lt;div class='green-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for ON LED</p><p> }</p><p> else{ //else output is inverted then</p><p> client.print(&quot; &lt;td&gt;&lt;div class='black-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for OFF LED</p><p> }</p><p> }</p><p> else //If Output is Off</p><p> {</p><p> if (outputInverted == false){ //and if output is not inverted</p><p> client.print(&quot; &lt;td&gt;&lt;div class='black-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for OFF LED</p><p> }</p><p> else{ //else output is inverted then</p><p> client.print(&quot; &lt;td&gt;&lt;div class='green-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for ON LED</p><p> }</p><p> }</p><p> //Print end of row</p><p> client.print(&quot;&lt;/tr&gt;\n&quot;);</p><p> }</p><p> //Display or hide the Print all on Pins Button</p><p> if (switchOnAllPinsButton == true ){</p><p> //Prints the ON All Pins Button</p><p> client.print(&quot;&lt;tr&gt;\n&lt;td&gt;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;Switch ON All Pins&quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?&quot;);</p><p> client.print(allOn);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&quot;);</p><p> //Prints the OFF All Pins Button</p><p> client.print(&quot;&lt;td&gt;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;Switch OFF All Pins&quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?&quot;);</p><p> client.print(allOff);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&lt;td&gt;&lt;/td&gt;\n&lt;td&gt;&lt;/td&gt;\n&lt;/tr&gt;\n&quot;);</p><p> }</p><p> //LOGOUT</p><p> //Closing the table and form</p><p> client.println(&quot;&lt;/table&gt;&quot;);</p><p> client.print(&quot;&lt;h3 align=\&quot;center\&quot;&gt;&lt;input type=button onClick=\&quot;location.href='/?Logout'\&quot; value='Logout'&gt;&lt;/h3&gt;&quot;); </p><p> client.println(&quot;&lt;/FORM&gt;&quot;);</p><p> //client.println(&quot;&lt;/p&gt;&quot;);</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//readOutputStatuses Function</p><p>////////////////////////////////////////////////////////////////////////</p><p> //Reading the Output Statuses</p><p> void readOutputStatuses(){</p><p> for (int var = 0; var &lt; outputQuantity; var++) {</p><p> outputStatus[var] = digitalRead(outputAddress[var]);</p><p> //Serial.print(outputStatus[var]);</p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//readEepromValues Function</p><p>////////////////////////////////////////////////////////////////////////</p><p> //Read EEprom values and save to outputStatus</p><p> void readEepromValues(){</p><p> for (int adr = 0; adr &lt; outputQuantity; adr++) {</p><p> outputStatus[adr] = EEPROM.read(adr);</p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//writeEepromValues Function</p><p>////////////////////////////////////////////////////////////////////////</p><p> //Write EEprom values</p><p> void writeEepromValues(){</p><p> for (int adr = 0; adr &lt; outputQuantity; adr++) {</p><p> EEPROM.write(adr, outputStatus[adr]);</p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//initEepromValues Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Initialiaze EEprom values</p><p>//if eeprom values are not the correct format ie not euqual to 0 or 1 (thus greater then 1) initialize by putting 0</p><p> void initEepromValues(){</p><p> for (int adr = 0; adr &lt; outputQuantity; adr++){</p><p> if (EEPROM.read(adr) &gt; 1){</p><p> EEPROM.write(adr, 0);</p><p> }</p><p> }</p><p> }</p><p>////////////////////////////////////////////////////////////////////////</p><p>//htmlHeader Function</p><p>////////////////////////////////////////////////////////////////////////</p><p> //Prints html header</p><p> void printHtmlHeader(EthernetClient client){</p><p> // Serial.print(&quot;Serving html Headers at ms -&quot;);</p><p> timeConnectedAt = millis(); //Record the time when last page was served.</p><p> // Serial.print(timeConnectedAt); // Print time for debbugging purposes</p><p> writeToEeprom = true; // page loaded so set to action the write to eeprom</p><p> // send a standard http response header</p><p> client.println(&quot;HTTP/1.1 200 OK&quot;);</p><p> client.println(&quot;Content-Type: text/html&quot;);</p><p> client.println(&quot;Connnection: close&quot;);</p><p> client.println();</p><p> client.println(&quot;&lt;!DOCTYPE HTML&gt;&quot;);</p><p> client.println(&quot;&lt;head&gt;&quot;);</p><p> // add page title</p><p> client.println(&quot;&lt;title&gt;MS * Controlle Pannel&lt;/title&gt;&quot;);</p><p> client.println(&quot;&lt;meta name=\&quot;description\&quot; content=\&quot;MS * Controlle Pannel\&quot;/&gt;&quot;);</p><p> // add a meta refresh tag, so the browser pulls again every x seconds:</p><p> client.print(&quot;&lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;&quot;);</p><p> client.print(refreshPage);</p><p> client.println(&quot;; url=/\&quot;&gt;&quot;);</p><p> // add other browser configuration</p><p> client.println(&quot;&lt;meta name=\&quot;apple-mobile-web-app-capable\&quot; content=\&quot;yes\&quot;&gt;&quot;);</p><p> client.println(&quot;&lt;meta name=\&quot;apple-mobile-web-app-status-bar-style\&quot; content=\&quot;default\&quot;&gt;&quot;);</p><p> client.println(&quot;&lt;meta name=\&quot;viewport\&quot; content=\&quot;width=device-width, user-scalable=no\&quot;&gt;&quot;);</p><p> //inserting the styles data, usually found in CSS files.</p><p> client.println(&quot;&lt;style type=\&quot;text/css\&quot;&gt;&quot;);</p><p> client.println(&quot;&quot;);</p><p> //This will set how the page will look graphically</p><p> client.println(&quot;html { height:100%; }&quot;);</p><p> client.println(&quot; body {&quot;);</p><p> client.println(&quot; height: 100%;&quot;);</p><p> client.println(&quot; margin: 0;&quot;);</p><p> client.println(&quot; font-family: helvetica, sans-serif;&quot;);</p><p> client.println(&quot; -webkit-text-size-adjust: none;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;body {&quot;);</p><p> client.println(&quot; -webkit-background-size: 100% 21px;&quot;);</p><p> client.println(&quot; background-color: #c5ccd3;&quot;);</p><p> client.println(&quot; background-image:&quot;);</p><p> client.println(&quot; -webkit-gradient(linear, left top, right top,&quot;);</p><p> client.println(&quot; color-stop(.75, transparent),&quot;);</p><p> client.println(&quot; color-stop(.75, rgba(255,255,255,.1)) );&quot;);</p><p> client.println(&quot; -webkit-background-size: 7px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.view {&quot;);</p><p> client.println(&quot; min-height: 100%;&quot;);</p><p> client.println(&quot; overflow: auto;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.header-wrapper {&quot;);</p><p> client.println(&quot; height: 44px;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: rgba(0,0,0,0.7) 0 -1px 0;&quot;);</p><p> client.println(&quot; border-top: solid 1px rgba(255,255,255,0.6);&quot;);</p><p> client.println(&quot; border-bottom: solid 1px rgba(0,0,0,0.6);&quot;);</p><p> client.println(&quot; color: #fff;&quot;);</p><p> client.println(&quot; background-color: #8195af;&quot;);</p><p> client.println(&quot; background-image:&quot;);</p><p> client.println(&quot; -webkit-gradient(linear, left top, left bottom,&quot;);</p><p> client.println(&quot; from(rgba(255,255,255,.4)),&quot;);</p><p> client.println(&quot; to(rgba(255,255,255,.05)) ),&quot;);</p><p> client.println(&quot; -webkit-gradient(linear, left top, left bottom,&quot;);</p><p> client.println(&quot; from(transparent),&quot;);</p><p> client.println(&quot; to(rgba(0,0,64,.1)) );&quot;);</p><p> client.println(&quot; background-repeat: no-repeat;&quot;);</p><p> client.println(&quot; background-position: top left, bottom left;&quot;);</p><p> client.println(&quot; -webkit-background-size: 100% 21px, 100% 22px;&quot;);</p><p> client.println(&quot; -webkit-box-sizing: border-box;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.header-wrapper h1 {&quot;);</p><p> client.println(&quot; text-align: center;&quot;);</p><p> client.println(&quot; font-size: 20px;&quot;);</p><p> client.println(&quot; line-height: 44px;&quot;);</p><p> client.println(&quot; margin: 0;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper {&quot;);</p><p> client.println(&quot; margin: 9px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper h2 {&quot;);</p><p> client.println(&quot; color: #4c566c;&quot;);</p><p> client.println(&quot; font-size: 17px;&quot;);</p><p> client.println(&quot; line-height: 0.8;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: #fff 0 1px 0;&quot;);</p><p> client.println(&quot; margin: 20px 10px 12px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper h3 {&quot;);</p><p> client.println(&quot; color: #4c566c;&quot;);</p><p> client.println(&quot; font-size: 12px;&quot;);</p><p> client.println(&quot; line-height: 1;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: #fff 0 1px 0;&quot;);</p><p> client.println(&quot; margin: 20px 10px 12px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper h4 {&quot;); //Text for description</p><p> client.println(&quot; color: #212121;&quot;);</p><p> client.println(&quot; font-size: 14px;&quot;);</p><p> client.println(&quot; line-height: 1;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: #aaa 1px 1px 3px;&quot;);</p><p> client.println(&quot; margin: 5px 5px 5px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper table {&quot;);</p><p> client.println(&quot; background-color: #fff;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 10px;&quot;);</p><p> client.println(&quot; -moz-border-radius: 10px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 10px;&quot;);</p><p> client.println(&quot; border-radius: 10px;&quot;);</p><p> client.println(&quot; font-size: 17px;&quot;);</p><p> client.println(&quot; line-height: 20px;&quot;);</p><p> client.println(&quot; margin: 9px 0 20px;&quot;);</p><p> client.println(&quot; border: solid 1px #a9abae;&quot;);</p><p> client.println(&quot; padding: 11px 3px 12px 3px;&quot;);</p><p> client.println(&quot; margin-left:auto;&quot;);</p><p> client.println(&quot; margin-right:auto;&quot;);</p><p> client.println(&quot; -moz-transform :scale(1);&quot;); //Code for Mozilla Firefox</p><p> client.println(&quot; -moz-transform-origin: 0 0;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //how the green (ON) LED will look</p><p> client.println(&quot;.green-circle {&quot;);</p><p> client.println(&quot; display: block;&quot;);</p><p> client.println(&quot; height: 23px;&quot;);</p><p> client.println(&quot; width: 23px;&quot;);</p><p> client.println(&quot; background-color: #0f0;&quot;);</p><p> //client.println(&quot; background-color: rgba(60, 132, 198, 0.8);&quot;);</p><p> client.println(&quot; -moz-border-radius: 11px;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 11px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 11px;&quot;);</p><p> client.println(&quot; border-radius: 11px;&quot;);</p><p> client.println(&quot; margin-left: 1px;&quot;);</p><p> client.println(&quot; background-image: -webkit-gradient(linear, 0% 0%, 0% 90%, from(rgba(46, 184, 0, 0.8)), to(rgba(148, 255, 112, .9)));@&quot;);</p><p> client.println(&quot; border: 2px solid #ccc;&quot;);</p><p> client.println(&quot; -webkit-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px;&quot;);</p><p> client.println(&quot; -moz-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;);</p><p> client.println(&quot; box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //how the black (off)LED will look</p><p> client.println(&quot;.black-circle {&quot;);</p><p> client.println(&quot; display: block;&quot;);</p><p> client.println(&quot; height: 23px;&quot;);</p><p> client.println(&quot; width: 23px;&quot;);</p><p> client.println(&quot; background-color: #040;&quot;);</p><p> client.println(&quot; -moz-border-radius: 11px;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 11px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 11px;&quot;);</p><p> client.println(&quot; border-radius: 11px;&quot;);</p><p> client.println(&quot; margin-left: 1px;&quot;);</p><p> client.println(&quot; -webkit-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px;&quot;);</p><p> client.println(&quot; -moz-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;);</p><p> client.println(&quot; box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //this will add the glare to both of the LEDs</p><p> client.println(&quot; .glare {&quot;);</p><p> client.println(&quot; position: relative;&quot;);</p><p> client.println(&quot; top: 1;&quot;);</p><p> client.println(&quot; left: 5px;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 10px;&quot;);</p><p> client.println(&quot; -moz-border-radius: 10px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 10px;&quot;);</p><p> client.println(&quot; border-radius: 10px;&quot;);</p><p> client.println(&quot; height: 1px;&quot;);</p><p> client.println(&quot; width: 13px;&quot;);</p><p> client.println(&quot; padding: 5px 0;&quot;);</p><p> client.println(&quot; background-color: rgba(200, 200, 200, 0.25);&quot;);</p><p> client.println(&quot; background-image: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.7)), to(rgba(255, 255, 255, 0)));&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //and finally this is the end of the style data and header</p><p> client.println(&quot;&lt;/style&gt;&quot;);</p><p> client.println(&quot;&lt;/head&gt;&quot;);</p><p> //now printing the page itself</p><p> client.println(&quot;&lt;body&gt;&quot;);</p><p> client.println(&quot;&lt;div class=\&quot;view\&quot;&gt;&quot;);</p><p> client.println(&quot; &lt;div class=\&quot;header-wrapper\&quot;&gt;&quot;);</p><p> client.println(&quot; &lt;h1&gt;MS * Controlle Pannel&lt;/h1&gt;&quot;);</p><p> client.println(&quot; &lt;/div&gt;&quot;);</p><p>} </p><p> //end of htmlHeader</p><p>////////////////////////////////////////////////////////////////////////</p><p>//htmlFooter Function</p><p>////////////////////////////////////////////////////////////////////////</p><p> //Prints html footer</p><p> void printHtmlFooter(EthernetClient client){</p><p> //Set Variables Before Exiting</p><p> printLastCommandOnce = false;</p><p> printButtonMenuOnce = false;</p><p> allOn = &quot;&quot;;</p><p> allOff = &quot;&quot;;</p><p> //printing last part of the html</p><p> client.println(&quot;\n&lt;h3 align=\&quot;center\&quot;&gt;Development - R. van Kouwen &lt;br&gt; 21 - January - 2016 - &quot;);</p><p> client.println(rev);</p><p> client.println(&quot;&lt;/h3&gt;&lt;/div&gt;\n&lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;&quot;);</p><p> delay(1); // give the web browser time to receive the data</p><p> client.stop(); // close the connection:</p><p> Serial.println(&quot; - Done, Closing Connection.&quot;);</p><p> delay (2); //delay so that it will give time for client buffer to clear and does not repeat multiple pages.</p><p>} </p><p>//end of htmlFooter</p><p>////////////////////////////////////////////////////////////////////////</p><p>//printHtmlButtonTitle Function</p><p>////////////////////////////////////////////////////////////////////////</p><p> //Prints html button title</p><p> void printHtmlButtonTitle(EthernetClient client){</p><p> client.println(&quot;&lt;div class=\&quot;group-wrapper\&quot;&gt;&quot;);</p><p> client.println(&quot; &lt;h2 align=\&quot;center\&quot;&gt;Switch Device output.&lt;/h2&gt;&quot;);</p><p> client.println();</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//printLoginTitle Function</p><p>////////////////////////////////////////////////////////////////////////</p><p> //Prints html button title</p><p> void printLoginTitle(EthernetClient client){</p><p> client.println(&quot;&lt;div class=\&quot;group-wrapper\&quot;&gt;&quot;);</p><p> //client.println(&quot;&lt;h2 align=\&quot;center\&quot;&gt;Welcome...&lt;/h2&gt;&quot;);</p><p> //client.println(&quot;&lt;h2 align=\&quot;center\&quot;&gt;Enter Username and Password.&lt;/h2&gt;&quot;);</p><p> client.println(&quot; &lt;/div&gt;&quot;);</p><p> client.print(&quot;&lt;form action='/'&gt;&quot;); //change to your IP</p><p> client.print(&quot;&quot;);</p><p> client.println(&quot; &lt;div class=\&quot;group-wrapper\&quot;&gt;&quot;);</p><p> client.print(&quot;&lt;h2 align=\&quot;center\&quot;&gt;Username:&lt;/h2&gt;&quot;);</p><p> client.print(&quot;&lt;h2 align=\&quot;center\&quot;&gt;&lt;input name='User' value=''&gt;&lt;/h2&gt;&quot;);</p><p> client.print(&quot;&lt;h2 align=\&quot;center\&quot;&gt;Password:&lt;/h2&gt;&quot;);</p><p> client.print(&quot;&lt;h2 align=\&quot;center\&quot;&gt;&lt;input type='Password' name='Pass' value=''&gt;&lt;/h2&gt;&quot;);</p><p> client.print(&quot;&lt;/div&gt;&quot;);</p><p> client.print(&quot;&lt;h2 align=\&quot;center\&quot;&gt;&lt;input type='submit' value=' Login '&gt;&lt;/h2&gt;&quot;);</p><p> //client.print(&quot;&lt;input type='submit' value=' Login '&gt;&quot;);</p><p> client.print(&quot;&lt;hr /&gt;&lt;/form&gt;&lt;hr /&gt;&quot;);</p><p> client.println(&quot;&lt;/head&gt;&lt;/center&gt;&quot;);</p><p>}</p><p>I </p>
<p>UserName : user</p><p>Password :user</p>
<p>User and password????</p>
<p>Why can't I even verify the sketch? I'm getting memory errors..</p>
<p>Make sure you change the Board type of Mega 2560..I got same thing ..my IDE defaulted to the UNO</p>
<p>Anyone manage to convert this to work with the EtherCard library ?</p>
<p>Hello sir, thank you so much for sharing your wonderful idea. I used your code with the login authentication. But when i login from my device, it is also accessible from other device without logging in on their own device.. :( </p>
<p>The login feature has been added by somebody else to my sketch. Unfortunately I have not yet tested it. I gave credit to the person that had done the login feature. Thus please find his name and contact him, maybe he can help.</p>
<p>Thanks for the reply sir, i already solved the problem in login feature.. But i got another problem. I am currently using 4 relay on my web switch.. But sometimes the Graphical user interface got broken like the html codes is being revealed.. </p>
<p>Hello, I'm from Brazil, I would like you solved the problem login?</p>
<p>Hello and thank you for this great project.</p><p>In my case I had to edit it and remove the OFF buttons. I renamed the ON button to ON/OFF button and I added a delay of 500ms. Thus by pressing the button the relay stays on for 500ms. </p><p>The problem I am facing is with the html LED (Green/Black). I want the LED display to be Black (off) and turn to ON once the button is pressed once. Eventhough the replay will turn off again due to the 500ms delay, I want the LED to stay ON (Green) until the next time the button is pressed.</p><p>Could anyone help me editing the coding here to get the LEDs turn ON and OFF based on the press of the button and not the actual relay status.</p><p>Thanking you in advance</p><p>Lambros</p>
<p>#include &lt;Ethernet.h&gt;</p><p>#include &lt;SPI.h&gt;</p><p>#include &lt;EEPROM.h&gt;</p><p>////////////////////////////////////////////////////////////////////////</p><p>//CONFIGURATION</p><p>////////////////////////////////////////////////////////////////////////</p><p>//IP manual settings</p><p>byte ip[] = {192, 168, 137, 100 }; //Manual setup only</p><p>byte gateway[] = {192, 168, 1, 1 }; //Manual setup only</p><p>byte subnet[] = {255, 255, 255, 0 }; //Manual setup only</p><p>byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };</p><p>//Ethernet Port</p><p>EthernetServer server = EthernetServer(80); //default html port 80</p><p>//The number of outputs going to be switched.</p><p>int outputQuantity = 16; //should not exceed 10 </p><p>//Invert the output of the leds</p><p>boolean outputInverted = false; //true or false</p><p>// This is done in case the relay board triggers the relay on negative, rather then on positive supply</p><p>//Html page refresh</p><p>int refreshPage = 15; //default is 10sec. </p><p>//Beware that if you make it refresh too fast, the page could become inacessable.</p><p>//Display or hide the &quot;Switch on all Pins&quot; buttons at the bottom of page</p><p>int switchOnAllPinsButton = false; //true or false</p><p>int outputAddress[] = { 22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37}; //Allocate 10 spaces and name the output pin address.</p><p>String buttonText[16] = {</p><p> &quot;01. Right Lamp&quot;,&quot;02. Left Lamp&quot;,&quot;03. Bedroom&quot;,&quot;04. Kitchen&quot;,&quot;05. Water Heater&quot;,&quot;06. Gate&quot;,&quot;07. Toilet&quot;,&quot;08. Main Heater&quot;,&quot;09. Roof Light&quot;,&quot;10. Basement&quot;,&quot;11. Test&quot;,&quot;12. TEST2&quot;,&quot;13. TEST3&quot;,&quot;14. TEST4&quot;,&quot;15. TEST5&quot;,&quot;16. TEST6&quot;};</p><p>// Set the output to retain the last status after power recycle.</p><p>int retainOutputStatus[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};//1-retain the last status. 0-will be off after power cut.</p><p>////////////////////////////////////////////////////////////////////////</p><p>//VARIABLES DECLARATION</p><p>////////////////////////////////////////////////////////////////////////</p><p>int outp = 0;</p><p>boolean printLastCommandOnce = false;</p><p>boolean printButtonMenuOnce = false;</p><p>boolean initialPrint = true;</p><p>String allOn = &quot;&quot;;</p><p>String allOff = &quot;&quot;;</p><p>boolean reading = false;</p><p>boolean outputStatus[16]; //Create a boolean array for the maximum ammount.</p><p>String rev = &quot;V4.06&quot;;</p><p>unsigned long timeConnectedAt;</p><p>boolean writeToEeprom = false;</p><p>/////////////////////////////////////////////////</p><p>// Temperature Related Reading</p><p>const int tempInPin = A1;</p><p>int tempInValue = 0; //temperature read</p><p>int tempScaleOutValue = 0; //temperature formatted</p><p>int tempOutValue = 0; //temperature formatted</p><p>float tempOutDeg = 0.0;</p><p>////////////////////////////////////////////////////////////////////////</p><p>//RUN ONCE</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Beginning of Program</p><p>void setup(){</p><p> Serial.begin(9600);</p><p> initEepromValues();</p><p> readEepromValues();</p><p> //Set pins as Outputs </p><p> boolean currentState = false;</p><p> int var;</p><p> for (int i = 0; i &lt; outputQuantity; i++){</p><p> pinMode(outputAddress[i], OUTPUT); </p><p> var = outputAddress[i];</p><p> //Switch all outputs to either on or off on Startup</p><p> if(outputInverted == true) {</p><p> //digitalWrite(outputAddress[var], HIGH);</p><p> if(outputStatus[i] == 0){currentState = true;}else{currentState = false;} //check outputStatus if off, switch output accordingly</p><p> digitalWrite(var, currentState);</p><p> }</p><p> else{</p><p> //digitalWrite(outputAddress[var], LOW);</p><p> if(outputStatus[i] == 0){currentState = false;}else{currentState = true;}//check outputStatus if off, switch output accordingly</p><p> digitalWrite(var, currentState);</p><p> }</p><p> }</p><p> //Setting up the IP address. Comment out the one you dont need.</p><p> //Ethernet.begin(mac); //for DHCP address. (Address will be printed to serial.)</p><p> Ethernet.begin(mac, ip, gateway, subnet); //for manual setup. (Address is the one configured above.)</p><p> server.begin();</p><p> Serial.print(&quot;Server started at &quot;);</p><p> Serial.println(Ethernet.localIP());</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//LOOP</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Run once</p><p>void loop(){</p><p> //Read Temperature Sensor</p><p> tempInValue = analogRead(tempInPin); </p><p> // Connecting a 10K3 Thermistor to the Arduino Input</p><p> // +5V �&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;[10Kohms]&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;[Thermistor]&mdash;&mdash;� 0V</p><p> // To Arduino IP �&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;|</p><p> tempScaleOutValue = map(tempInValue, 0, 1023, 1023, 0); //Arduino value and NTC of the 10K3 Thermistor</p><p> tempOutValue = map(tempScaleOutValue, 130, 870, -170, 730); //range of Arduino Value compared with Temperature</p><p> tempOutValue = tempOutValue -45; //Adjustments</p><p> tempOutDeg = tempOutValue / 10.0;</p><p> checkForClient();</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//checkForClient Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//</p><p>void checkForClient(){</p><p> EthernetClient client = server.available();</p><p> if (client) {</p><p> boolean currentLineIsBlank = true;</p><p> boolean sentHeader = false;</p><p> int temp,temp1;</p><p> while (client.connected()) {</p><p> if (client.available()) {</p><p> char c = client.read();</p><p> if(c == '*'){</p><p> printHtmlHeader(client); //call for html header and css</p><p> printLoginTitle(client);</p><p> printHtmlFooter(client);</p><p> break;</p><p> }</p><p> if(!sentHeader){</p><p> printHtmlHeader(client); //call for html header and css</p><p> printHtmlButtonTitle(client); //print the button title</p><p> sentHeader = true;</p><p> }</p><p> if(reading &amp;&amp; c == ' '){</p><p> reading = false;</p><p> }</p><p> if(c == '?') {</p><p> reading = true; //found the ?, begin reading the info</p><p> }</p><p> if(reading){</p><p> //if user input is H set output to 1</p><p> if(c == 'H') {</p><p> outp = 1;</p><p> }</p><p> if(c == 'L') {</p><p> outp = 0;</p><p> }</p><p>// Serial.println(c); //print the value of c to serial communication</p><p>//---------------------------------------------------------------------------------------------</p><p>// ? H 1 0</p><p>// ^ ^ ^ ^</p><p>// | | | |____________read 4 ( 10,11,12,13....)</p><p>// | | |______________read 3 ( 1....9)</p><p>// | |________________read 2 if user input is H set output to L</p><p>// |__________________read 1</p><p>//---------------------------------------------------------------------------------------------</p><p> if( c == '1'){</p><p> char c = client.read();</p><p> switch (c) {</p><p> case '0':</p><p> triggerPin(outputAddress[10], client, outp);</p><p> break; </p><p> case '1':</p><p> triggerPin(outputAddress[11], client, outp);</p><p> break; </p><p> case '2':</p><p> triggerPin(outputAddress[12], client, outp);</p><p> break;</p><p> case '3':</p><p> triggerPin(outputAddress[13], client, outp);</p><p> break;</p><p> case '4':</p><p> triggerPin(outputAddress[14], client, outp);</p><p> break;</p><p> case '5':</p><p> triggerPin(outputAddress[15], client, outp);</p><p> break;</p><p> default:</p><p> char c = client.read();</p><p> triggerPin(outputAddress[1], client, outp);</p><p> }</p><p> }</p><p> else {</p><p> switch (c) {</p><p> case '0':</p><p> triggerPin(outputAddress[0], client, outp);</p><p> break; </p><p> // case '1':</p><p> // triggerPin(outputAddress[1], client, outp);</p><p> // break; </p><p> case '2':</p><p> triggerPin(outputAddress[2], client, outp);</p><p> break;</p><p> case '3':</p><p> //add code here to trigger on 3</p><p> triggerPin(outputAddress[3], client, outp);</p><p> break;</p><p> case '4':</p><p> //add code here to trigger on 4</p><p> triggerPin(outputAddress[4], client, outp);</p><p> break;</p><p> case '5':</p><p> //add code here to trigger on 5</p><p> triggerPin(outputAddress[5], client, outp);</p><p> //printHtml(client);</p><p> break;</p><p> case '6':</p><p> //add code here to trigger on 6</p><p> triggerPin(outputAddress[6], client, outp);</p><p> break;</p><p> case '7':</p><p> //add code here to trigger on 7</p><p> triggerPin(outputAddress[7], client, outp);</p><p> break;</p><p> case '8':</p><p> //add code here to trigger on 8</p><p> triggerPin(outputAddress[8], client, outp);</p><p> break;</p><p> case '9':</p><p> //add code here to trigger on 9</p><p> triggerPin(outputAddress[9], client, outp);</p><p> break;</p><p> } //end of switch case</p><p> } </p><p> }//end of switch switch the relevant output </p><p> //if user input was blank</p><p> if (c == '\n' &amp;&amp; currentLineIsBlank){</p><p> printLastCommandOnce = true;</p><p> printButtonMenuOnce = true;</p><p> triggerPin(777, client, outp); //Call to read input and print menu. 777 is used not to update any outputs</p><p> break;</p><p> }</p><p> }</p><p> }</p><p> printHtmlFooter(client); //Prints the html footer</p><p> } </p><p> else{ </p><p> if (millis() &gt; (timeConnectedAt + 60000)){ </p><p> if (writeToEeprom == true){ </p><p> writeEepromValues(); //write to EEprom the current output statuses</p><p> Serial.println(&quot;No Clients for more then a minute - Writing statuses to Eeprom.&quot;);</p><p> writeToEeprom = false;</p><p> }</p><p> }</p><p> }</p><p>}// END</p><p>////////////////////////////////////////////////////////////////////////</p><p>//triggerPin Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//</p><p>void triggerPin(int pin, EthernetClient client, int outp){</p><p> if (pin != 777){ </p><p>// Serial.println(pin);</p><p> if(outp == 1) {</p><p> if (outputInverted ==false){ </p><p> digitalWrite(pin, HIGH);</p><p> } </p><p> else{</p><p> digitalWrite(pin, LOW);</p><p> }</p><p> }</p><p> if(outp == 0){</p><p> if (outputInverted ==false){ </p><p> digitalWrite(pin, LOW);</p><p> } </p><p> else{</p><p> digitalWrite(pin, HIGH);</p><p> }</p><p> }</p><p> }</p><p> //Refresh the reading of outputs</p><p> readOutputStatuses();</p><p> //Prints the buttons</p><p> if (printButtonMenuOnce == true){</p><p> printHtmlButtons(client);</p><p> printButtonMenuOnce = false;</p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//printHtmlButtons Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//print the html buttons to switch on/off channels</p><p>void printHtmlButtons(EthernetClient client){</p><p> //Start to create the html table</p><p> client.println(&quot;&quot;);</p><p> //client.println(&quot;&lt;p&gt;&quot;);</p><p> client.println(&quot;&lt;FORM&gt;&quot;);</p><p> client.println(&quot;&lt;table border=\&quot;0\&quot; align=\&quot;center\&quot;&gt;&quot;);</p><p> //Printing the Temperature</p><p> client.print(&quot;&lt;tr&gt;\n&quot;); </p><p> client.print(&quot;&lt;td&gt;&lt;h4&gt;&quot;);</p><p> client.print(&quot;Temperature&quot;);</p><p> client.print(&quot;&lt;/h4&gt;&lt;/td&gt;\n&quot;);</p><p> client.print(&quot;&lt;td&gt;&lt;/td&gt;&quot;); </p><p> client.print(&quot;&lt;td&gt;&quot;);</p><p> client.print(&quot;&lt;h3&gt;&quot;);</p><p> client.print(tempOutDeg);</p><p> client.print(&quot; &deg;C&lt;/h3&gt;&lt;/td&gt;\n&quot;);</p><p> client.print(&quot;&lt;td&gt;&lt;/td&gt;&quot;);</p><p> client.print(&quot;&lt;/tr&gt;&quot;);</p><p> //Start printing button by button</p><p> for (int var = 0; var &lt; outputQuantity; var++) { </p><p> //set command for all on/off</p><p> allOn += &quot;H&quot;;</p><p> allOn += outputAddress[var];</p><p> allOff += &quot;L&quot;;</p><p> allOff += outputAddress[var];</p><p> //Print begining of row</p><p> client.print(&quot;&lt;tr&gt;\n&quot;); </p><p> //Prints the button Text</p><p> client.print(&quot;&lt;td&gt;&lt;h4&gt;&quot;);</p><p> client.print(buttonText[var]);</p><p> client.print(&quot;&lt;/h4&gt;&lt;/td&gt;\n&quot;);</p><p> //Prints the ON Buttons+++++++++++++++++++++++++++++++++++++++++++++++</p><p> client.print(&quot;&lt;td&gt;&quot;);</p><p> client.print(&quot;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;ON &quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?H&quot;);</p><p> client.print(var);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&quot;);</p><p> //Prints the OFF Buttons ---------------------------------------------</p><p> client.print(&quot; &lt;td&gt;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;OFF&quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?L&quot;);</p><p> client.print(var);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&quot;);</p><p> //Invert the LED display if output is inverted.</p><p> if (outputStatus[var] == true ){ //If Output is ON</p><p> if (outputInverted == false){ //and if output is not inverted </p><p> client.print(&quot; &lt;td&gt;&lt;div class='green-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for ON LED</p><p> }</p><p> else{ //else output is inverted then</p><p> client.print(&quot; &lt;td&gt;&lt;div class='black-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for OFF LED</p><p> }</p><p> }</p><p> else //If Output is Off</p><p> {</p><p> if (outputInverted == false){ //and if output is not inverted</p><p> client.print(&quot; &lt;td&gt;&lt;div class='black-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for OFF LED</p><p> }</p><p> else{ //else output is inverted then </p><p> client.print(&quot; &lt;td&gt;&lt;div class='green-circle'&gt;&lt;div class='glare'&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;\n&quot;); //Print html for ON LED </p><p> }</p><p> } </p><p> //Print end of row</p><p> client.print(&quot;&lt;/tr&gt;\n&quot;); </p><p> }</p><p> //Display or hide the Print all on Pins Button</p><p> if (switchOnAllPinsButton == true ){</p><p> //Prints the ON All Pins Button</p><p> client.print(&quot;&lt;tr&gt;\n&lt;td&gt;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;Switch ON All Pins&quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?&quot;);</p><p> client.print(allOn);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&quot;);</p><p> //Prints the OFF All Pins Button </p><p> client.print(&quot;&lt;td&gt;&lt;INPUT TYPE=\&quot;button\&quot; VALUE=\&quot;Switch OFF All Pins&quot;);</p><p> client.print(&quot;\&quot; onClick=\&quot;parent.location='/?&quot;);</p><p> client.print(allOff);</p><p> client.print(&quot;'\&quot;&gt;&lt;/td&gt;\n&lt;td&gt;&lt;/td&gt;\n&lt;td&gt;&lt;/td&gt;\n&lt;/tr&gt;\n&quot;);</p><p> }</p><p> //Closing the table and form</p><p> client.println(&quot;&lt;/table&gt;&quot;);</p><p> client.println(&quot;&lt;/FORM&gt;&quot;);</p><p> //client.println(&quot;&lt;/p&gt;&quot;); </p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//readOutputStatuses Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Reading the Output Statuses</p><p>void readOutputStatuses(){</p><p> for (int var = 0; var &lt; outputQuantity; var++) { </p><p> outputStatus[var] = digitalRead(outputAddress[var]);</p><p> //Serial.print(outputStatus[var]);</p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//readEepromValues Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Read EEprom values and save to outputStatus</p><p>void readEepromValues(){</p><p> for (int adr = 0; adr &lt; outputQuantity; adr++) { </p><p> outputStatus[adr] = EEPROM.read(adr); </p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//writeEepromValues Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Write EEprom values</p><p>void writeEepromValues(){</p><p> for (int adr = 0; adr &lt; outputQuantity; adr++) { </p><p> EEPROM.write(adr, outputStatus[adr]);</p><p> }</p><p>} </p><p>////////////////////////////////////////////////////////////////////////</p><p>//initEepromValues Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Initialiaze EEprom values</p><p>//if eeprom values are not the correct format ie not euqual to 0 or 1 (thus greater then 1) initialize by putting 0</p><p>void initEepromValues(){</p><p> for (int adr = 0; adr &lt; outputQuantity; adr++){ </p><p> if (EEPROM.read(adr) &gt; 1){</p><p> EEPROM.write(adr, 0);</p><p> } </p><p> }</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//htmlHeader Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Prints html header</p><p> void printHtmlHeader(EthernetClient client){</p><p> // Serial.print(&quot;Serving html Headers at ms -&quot;);</p><p> timeConnectedAt = millis(); //Record the time when last page was served.</p><p> // Serial.print(timeConnectedAt); // Print time for debbugging purposes</p><p> writeToEeprom = true; // page loaded so set to action the write to eeprom</p><p> // send a standard http response header</p><p> client.println(&quot;HTTP/1.1 200 OK&quot;);</p><p> client.println(&quot;Content-Type: text/html&quot;);</p><p> client.println(&quot;Connnection: close&quot;);</p><p> client.println();</p><p> client.println(&quot;&lt;!DOCTYPE HTML&gt;&quot;);</p><p> client.println(&quot;&lt;head&gt;&quot;);</p><p> // add page title </p><p> client.println(&quot;&lt;title&gt;Ethernet Switching&lt;/title&gt;&quot;);</p><p> client.println(&quot;&lt;meta name=\&quot;description\&quot; content=\&quot;Ethernet Switching\&quot;/&gt;&quot;);</p><p> // add a meta refresh tag, so the browser pulls again every x seconds:</p><p> client.print(&quot;&lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;&quot;);</p><p> client.print(refreshPage);</p><p> client.println(&quot;; url=/\&quot;&gt;&quot;);</p><p> // add other browser configuration</p><p> client.println(&quot;&lt;meta name=\&quot;apple-mobile-web-app-capable\&quot; content=\&quot;yes\&quot;&gt;&quot;);</p><p> client.println(&quot;&lt;meta name=\&quot;apple-mobile-web-app-status-bar-style\&quot; content=\&quot;default\&quot;&gt;&quot;);</p><p> client.println(&quot;&lt;meta name=\&quot;viewport\&quot; content=\&quot;width=device-width, user-scalable=no\&quot;&gt;&quot;); </p><p> //inserting the styles data, usually found in CSS files.</p><p> client.println(&quot;&lt;style type=\&quot;text/css\&quot;&gt;&quot;);</p><p> client.println(&quot;&quot;);</p><p> //This will set how the page will look graphically</p><p> client.println(&quot;html { height:100%; }&quot;); </p><p> client.println(&quot; body {&quot;);</p><p> client.println(&quot; height: 100%;&quot;);</p><p> client.println(&quot; margin: 0;&quot;);</p><p> client.println(&quot; font-family: helvetica, sans-serif;&quot;);</p><p> client.println(&quot; -webkit-text-size-adjust: none;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;body {&quot;);</p><p> client.println(&quot; -webkit-background-size: 100% 21px;&quot;);</p><p> client.println(&quot; background-color: #c5ccd3;&quot;);</p><p> client.println(&quot; background-image:&quot;);</p><p> client.println(&quot; -webkit-gradient(linear, left top, right top,&quot;);</p><p> client.println(&quot; color-stop(.75, transparent),&quot;);</p><p> client.println(&quot; color-stop(.75, rgba(255,255,255,.1)) );&quot;);</p><p> client.println(&quot; -webkit-background-size: 7px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.view {&quot;);</p><p> client.println(&quot; min-height: 100%;&quot;);</p><p> client.println(&quot; overflow: auto;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.header-wrapper {&quot;);</p><p> client.println(&quot; height: 44px;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: rgba(0,0,0,0.7) 0 -1px 0;&quot;);</p><p> client.println(&quot; border-top: solid 1px rgba(255,255,255,0.6);&quot;);</p><p> client.println(&quot; border-bottom: solid 1px rgba(0,0,0,0.6);&quot;);</p><p> client.println(&quot; color: #fff;&quot;);</p><p> client.println(&quot; background-color: #8195af;&quot;);</p><p> client.println(&quot; background-image:&quot;);</p><p> client.println(&quot; -webkit-gradient(linear, left top, left bottom,&quot;);</p><p> client.println(&quot; from(rgba(255,255,255,.4)),&quot;);</p><p> client.println(&quot; to(rgba(255,255,255,.05)) ),&quot;);</p><p> client.println(&quot; -webkit-gradient(linear, left top, left bottom,&quot;);</p><p> client.println(&quot; from(transparent),&quot;);</p><p> client.println(&quot; to(rgba(0,0,64,.1)) );&quot;);</p><p> client.println(&quot; background-repeat: no-repeat;&quot;);</p><p> client.println(&quot; background-position: top left, bottom left;&quot;);</p><p> client.println(&quot; -webkit-background-size: 100% 21px, 100% 22px;&quot;);</p><p> client.println(&quot; -webkit-box-sizing: border-box;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.header-wrapper h1 {&quot;);</p><p> client.println(&quot; text-align: center;&quot;);</p><p> client.println(&quot; font-size: 20px;&quot;);</p><p> client.println(&quot; line-height: 44px;&quot;);</p><p> client.println(&quot; margin: 0;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper {&quot;);</p><p> client.println(&quot; margin: 9px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper h2 {&quot;);</p><p> client.println(&quot; color: #4c566c;&quot;);</p><p> client.println(&quot; font-size: 17px;&quot;);</p><p> client.println(&quot; line-height: 0.8;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: #fff 0 1px 0;&quot;);</p><p> client.println(&quot; margin: 20px 10px 12px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper h3 {&quot;);</p><p> client.println(&quot; color: #4c566c;&quot;);</p><p> client.println(&quot; font-size: 12px;&quot;);</p><p> client.println(&quot; line-height: 1;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: #fff 0 1px 0;&quot;);</p><p> client.println(&quot; margin: 20px 10px 12px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> client.println(&quot;.group-wrapper h4 {&quot;); //Text for description</p><p> client.println(&quot; color: #212121;&quot;);</p><p> client.println(&quot; font-size: 14px;&quot;);</p><p> client.println(&quot; line-height: 1;&quot;);</p><p> client.println(&quot; font-weight: bold;&quot;);</p><p> client.println(&quot; text-shadow: #aaa 1px 1px 3px;&quot;);</p><p> client.println(&quot; margin: 5px 5px 5px;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;); </p><p> client.println(&quot;.group-wrapper table {&quot;);</p><p> client.println(&quot; background-color: #fff;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 10px;&quot;);</p><p> client.println(&quot; -moz-border-radius: 10px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 10px;&quot;);</p><p> client.println(&quot; border-radius: 10px;&quot;);</p><p> client.println(&quot; font-size: 17px;&quot;);</p><p> client.println(&quot; line-height: 20px;&quot;);</p><p> client.println(&quot; margin: 9px 0 20px;&quot;);</p><p> client.println(&quot; border: solid 1px #a9abae;&quot;);</p><p> client.println(&quot; padding: 11px 3px 12px 3px;&quot;);</p><p> client.println(&quot; margin-left:auto;&quot;);</p><p> client.println(&quot; margin-right:auto;&quot;);</p><p> client.println(&quot; -moz-transform :scale(1);&quot;); //Code for Mozilla Firefox</p><p> client.println(&quot; -moz-transform-origin: 0 0;&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //how the green (ON) LED will look</p><p> client.println(&quot;.green-circle {&quot;);</p><p> client.println(&quot; display: block;&quot;);</p><p> client.println(&quot; height: 23px;&quot;);</p><p> client.println(&quot; width: 23px;&quot;);</p><p> client.println(&quot; background-color: #0f0;&quot;);</p><p> //client.println(&quot; background-color: rgba(60, 132, 198, 0.8);&quot;);</p><p> client.println(&quot; -moz-border-radius: 11px;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 11px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 11px;&quot;);</p><p> client.println(&quot; border-radius: 11px;&quot;);</p><p> client.println(&quot; margin-left: 1px;&quot;);</p><p> client.println(&quot; background-image: -webkit-gradient(linear, 0% 0%, 0% 90%, from(rgba(46, 184, 0, 0.8)), to(rgba(148, 255, 112, .9)));@&quot;);</p><p> client.println(&quot; border: 2px solid #ccc;&quot;);</p><p> client.println(&quot; -webkit-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px;&quot;);</p><p> client.println(&quot; -moz-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;);</p><p> client.println(&quot; box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //how the black (off)LED will look</p><p> client.println(&quot;.black-circle {&quot;);</p><p> client.println(&quot; display: block;&quot;);</p><p> client.println(&quot; height: 23px;&quot;);</p><p> client.println(&quot; width: 23px;&quot;);</p><p> client.println(&quot; background-color: #040;&quot;);</p><p> client.println(&quot; -moz-border-radius: 11px;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 11px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 11px;&quot;);</p><p> client.println(&quot; border-radius: 11px;&quot;);</p><p> client.println(&quot; margin-left: 1px;&quot;);</p><p> client.println(&quot; -webkit-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px;&quot;);</p><p> client.println(&quot; -moz-box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;); </p><p> client.println(&quot; box-shadow: rgba(11, 140, 27, 0.5) 0px 10px 16px; /* FF 3.5+ */&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //this will add the glare to both of the LEDs</p><p> client.println(&quot; .glare {&quot;);</p><p> client.println(&quot; position: relative;&quot;);</p><p> client.println(&quot; top: 1;&quot;);</p><p> client.println(&quot; left: 5px;&quot;);</p><p> client.println(&quot; -webkit-border-radius: 10px;&quot;);</p><p> client.println(&quot; -moz-border-radius: 10px;&quot;);</p><p> client.println(&quot; -khtml-border-radius: 10px;&quot;);</p><p> client.println(&quot; border-radius: 10px;&quot;);</p><p> client.println(&quot; height: 1px;&quot;);</p><p> client.println(&quot; width: 13px;&quot;);</p><p> client.println(&quot; padding: 5px 0;&quot;);</p><p> client.println(&quot; background-color: rgba(200, 200, 200, 0.25);&quot;);</p><p> client.println(&quot; background-image: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.7)), to(rgba(255, 255, 255, 0)));&quot;);</p><p> client.println(&quot; }&quot;);</p><p> client.println(&quot;&quot;);</p><p> //and finally this is the end of the style data and header</p><p> client.println(&quot;&lt;/style&gt;&quot;);</p><p> client.println(&quot;&lt;/head&gt;&quot;);</p><p> //now printing the page itself</p><p> client.println(&quot;&lt;body&gt;&quot;);</p><p> client.println(&quot;&lt;div class=\&quot;view\&quot;&gt;&quot;);</p><p> client.println(&quot; &lt;div class=\&quot;header-wrapper\&quot;&gt;&quot;);</p><p> client.println(&quot; &lt;h1&gt;Ethernet Switching&lt;/h1&gt;&quot;);</p><p> client.println(&quot; &lt;/div&gt;&quot;);</p><p>//////</p><p> } //end of htmlHeader</p><p>////////////////////////////////////////////////////////////////////////</p><p>//htmlFooter Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Prints html footer</p><p>void printHtmlFooter(EthernetClient client){</p><p> //Set Variables Before Exiting </p><p> printLastCommandOnce = false;</p><p> printButtonMenuOnce = false;</p><p> allOn = &quot;&quot;;</p><p> allOff = &quot;&quot;;</p><p> //printing last part of the html</p><p> client.println(&quot;\n&lt;h3 align=\&quot;center\&quot;&gt;Development - Chinh Truc &lt;br&gt; 01 - August - 2014 - V5.0&quot;);</p><p> client.println(&quot;\n&lt;h3 align=\&quot;center\&quot;&gt;&copy; Author - Claudio Vella &lt;br&gt; Malta - October - 2012 - &quot;);</p><p> client.println(rev);</p><p> client.println(&quot;&lt;/h3&gt;&lt;/div&gt;\n&lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;&quot;);</p><p> delay(1); // give the web browser time to receive the data</p><p> client.stop(); // close the connection:</p><p> Serial.println(&quot; - Done, Closing Connection.&quot;);</p><p> delay (2); //delay so that it will give time for client buffer to clear and does not repeat multiple pages.</p><p> } //end of htmlFooter</p><p>////////////////////////////////////////////////////////////////////////</p><p>//printHtmlButtonTitle Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Prints html button title</p><p>void printHtmlButtonTitle(EthernetClient client){</p><p> client.println(&quot;&lt;div class=\&quot;group-wrapper\&quot;&gt;&quot;);</p><p> client.println(&quot; &lt;h2&gt;Switch Device output.&lt;/h2&gt;&quot;);</p><p> client.println();</p><p>}</p><p>////////////////////////////////////////////////////////////////////////</p><p>//printLoginTitle Function</p><p>////////////////////////////////////////////////////////////////////////</p><p>//Prints html button title</p><p>void printLoginTitle(EthernetClient client){</p><p> // client.println(&quot;&lt;div class=\&quot;group-wrapper\&quot;&gt;&quot;);</p><p> client.println(&quot; &lt;h2&gt;Please enter the user data to login.&lt;/h2&gt;&quot;);</p><p> client.println();</p><p>}</p>
<p>Hey , its very nice, but the all on and all of function , does not work properly. It can't turn on and off all relays only the first 10. </p><p>Can you help me solve this problem ? Best regards Kalin !</p>
<p>please help me to make 32 relays.....</p>
<p>Hi</p><p>How to combine with the bluetooth code I wrote this code you developed?</p><p>Thanks to our contributors</p><p>//-------------------DO NOT EDIT AFTER THIS LINE------------------------// </p><p>String voice;</p><p>int </p><p>rel1 = 2,</p><p>rel2 = 3,</p><p>rel3 = 4,</p><p>rel4 = 5,</p><p>rel5 = 6,</p><p>rel6 = 7,</p><p>rel7 = 8,</p><p>rel8 = 9;</p><p>void alloff(){</p><p>digitalWrite(rel1, LOW); </p><p>digitalWrite(rel2, LOW); </p><p>digitalWrite(rel3, LOW); </p><p>digitalWrite(rel4, LOW); </p><p>digitalWrite(rel5, LOW); </p><p>digitalWrite(rel6, LOW); </p><p>digitalWrite(rel7, LOW); </p><p>digitalWrite(rel8, LOW); </p><p>}</p><p>void allon(){</p><p>digitalWrite(rel1, HIGH); </p><p>digitalWrite(rel2, HIGH); </p><p>digitalWrite(rel3, HIGH); </p><p>digitalWrite(rel4, HIGH); </p><p>digitalWrite(rel5, HIGH);</p><p>digitalWrite(rel6, HIGH); </p><p>digitalWrite(rel7, HIGH); </p><p>digitalWrite(rel8, HIGH);</p><p>}</p><p>void setup() {</p><p>Serial.begin(9600);</p><p>pinMode(rel1, OUTPUT); </p><p>pinMode(rel2, OUTPUT); </p><p>pinMode(rel3, OUTPUT); </p><p>pinMode(rel4, OUTPUT); </p><p>pinMode(rel5, OUTPUT); </p><p>pinMode(rel6, OUTPUT); </p><p>pinMode(rel7, OUTPUT); </p><p>pinMode(rel8, OUTPUT);</p><p>//----------------------Set Relays state the begin-------------------//</p><p>digitalWrite(rel1, HIGH);</p><p>digitalWrite(rel2, HIGH);</p><p>digitalWrite(rel3, HIGH);</p><p>digitalWrite(rel4, HIGH);</p><p>digitalWrite(rel5, HIGH);</p><p>digitalWrite(rel6, HIGH);</p><p>digitalWrite(rel7, HIGH);</p><p>digitalWrite(rel8, HIGH);</p><p>}</p><p>void loop() {</p><p>while (Serial.available()){</p><p>delay(10);</p><p>char c = Serial.read();</p><p>if (c == '#') {break;}</p><p>voice += c;</p><p>} </p><p>if (voice.length() &gt; 0) {</p><p>Serial.println(voice); </p><p>//-------------------DO NOT EDIT BEFORE THIS LINE------------------------// </p><p>//</p><p>//</p><p>//</p><p>//</p><p>//----------****************START USER DEFINED CODE**********************-------------//</p><p>//--------------------------Control all relays state----------------------------------//</p><p>//--Here is place where can edit words that must be told to change the state of all relays at the same time.Please edit words &quot;*all on&quot; and &quot;*all off&quot; with words that you prefer to control all outputs. ex. &quot;*panic on&quot; and &quot;*panic off&quot;. Please keep structure of the algorithm, &quot; and * are important, dont delete them when edit words.--//</p><p>if(voice == &quot;*hepsini kapat&quot;) {allon();} //Turn Off All Relays outputs</p><p>if(voice == &quot;*sini kapat&quot;) {allon();} //Turn Off All Relays outputs</p><p>if(voice == &quot;*kapat&quot;) {allon();} //Turn Off All Relays outputs</p><p>else if(voice == &quot;*hepsini a&ccedil;&quot;){alloff();} //Turn On All Relays outputs</p><p>else if(voice == &quot;*sini a&ccedil;&quot;){alloff();} //Turn On All Relays outputs</p><p>else if(voice == &quot;*a&ccedil;&quot;){alloff();} //Turn On All Relays outputs</p><p>//--------------------------Control seperate relay state------------------------------//</p><p>//--------------------------It can work in many languages-----------------------------//</p><p>//---------------------------Example Bulgarian and English---------------------------//</p><p>else if(voice == &quot;*ışıkları a&ccedil;&quot;) {digitalWrite(rel1, LOW);} //Turn On 1 Relay output</p><p>else if(voice == &quot;*tv a&ccedil;&quot;) {digitalWrite(rel2, LOW);} //Turn On 2 Relay output</p><p>else if(voice == &quot;*tv yi a&ccedil;&quot;) {digitalWrite(rel2, LOW);} //Turn On 2 Relay output</p><p>else if(voice == &quot;*server a&ccedil;&quot;) {digitalWrite(rel3, LOW);} //Turn On 3 Relay output</p><p>else if(voice == &quot;*s&ouml;z ver bağlan&quot;) {digitalWrite(rel3, LOW);} //Turn On 3 Relay output</p><p>else if(voice == &quot;*s&ouml;zver bağlan&quot;) {digitalWrite(rel3, LOW);} //Turn On 3 Relay output</p><p>else if(voice == &quot;*s&ouml;z ver a&ccedil;&quot;) {digitalWrite(rel3, LOW);} //Turn On 3 Relay output</p><p>else if(voice == &quot;*klima a&ccedil;&quot;) {digitalWrite(rel4, LOW);} //Turn On 4 Relay output</p><p>else if(voice == &quot;*klima yı a&ccedil;&quot;) {digitalWrite(rel4, LOW);} //Turn On 4 Relay output</p><p>else if(voice == &quot;*klimayı a&ccedil;&quot;) {digitalWrite(rel4, LOW);} //Turn On 4 Relay output</p><p>else if(voice == &quot;*alarm a&ccedil;&quot;) {digitalWrite(rel5, LOW);} //Turn On 5 Relay output</p><p>else if(voice == &quot;*kapıyı a&ccedil;&quot;) {digitalWrite(rel6, LOW);} //Turn On 6 Relay output</p><p>else if(voice == &quot;*kapı a&ccedil;&quot;) {digitalWrite(rel6, LOW);} //Turn On 6 Relay output</p><p>else if(voice == &quot;*garaj kapısını a&ccedil;&quot;) {digitalWrite(rel7, LOW);} //Turn On 7 Relay output</p><p>else if(voice == &quot;*garaj kapı a&ccedil;&quot;) {digitalWrite(rel7, LOW);} //Turn On 7 Relay output</p><p>else if(voice == &quot;*perde a&ccedil;&quot;) {digitalWrite(rel8, LOW);} //Turn On 8 Relay output</p><p>else if(voice == &quot;*perdeyi a&ccedil;&quot;) {digitalWrite(rel8, LOW);} //Turn On 8 Relay output</p><p>else if(voice == &quot;*ferdi a&ccedil;&quot;) {digitalWrite(rel8, LOW);} //Turn On 8 Relay output</p><p>else if(voice == &quot;*ferdiyi a&ccedil;&quot;) {digitalWrite(rel8, LOW);} //Turn On 8 Relay output</p><p>//</p><p>else if(voice == &quot;*ışıkları kapat&quot;) {digitalWrite(rel1, HIGH);} //Turn Off 1 Relay output</p><p>else if(voice == &quot;*tv kapat&quot;) {digitalWrite(rel2, HIGH);} //Turn Off 2 Relay output</p><p>else if(voice == &quot;*tv yi kapat&quot;) {digitalWrite(rel2, HIGH);} //Turn Off 2 Relay output</p><p>else if(voice == &quot;*server kapat&quot;) {digitalWrite(rel3, HIGH);} //Turn Off 3 Relay output</p><p>else if(voice == &quot;*s&ouml;z ver kapat&quot;) {digitalWrite(rel3, HIGH);} //Turn Off 3 Relay output</p><p>else if(voice == &quot;*klima kapat&quot;) {digitalWrite(rel4, HIGH);} //Turn Off 4 Relay output</p><p>else if(voice == &quot;*klima kapa&quot;) {digitalWrite(rel4, HIGH);} //Turn Off 4 Relay output</p><p>else if(voice == &quot;*klimayı kapat&quot;) {digitalWrite(rel4, HIGH);} //Turn Off 4 Relay output</p><p>else if(voice == &quot;*klima yı kapat&quot;) {digitalWrite(rel4, HIGH);} //Turn Off 4 Relay output</p><p>else if(voice == &quot;*klima yı kapa&quot;) {digitalWrite(rel4, HIGH);} //Turn Off 4 Relay output</p><p>else if(voice == &quot;*alarm kapat&quot;) {digitalWrite(rel5, HIGH);} //Turn Off 5 Relay output</p><p>else if(voice == &quot;*kapıyı kapat&quot;) {digitalWrite(rel6, HIGH);} //Turn Off 6 Relay output</p><p>else if(voice == &quot;*kapı kapat&quot;) {digitalWrite(rel6, HIGH);} //Turn Off 6 Relay output</p><p>else if(voice == &quot;*kapıyı kapat&quot;) {digitalWrite(rel6, HIGH);} //Turn Off 6 Relay output</p><p>else if(voice == &quot;*garaj kapı kapat&quot;) {digitalWrite(rel7, HIGH);} //Turn Off 7 Relay output</p><p>else if(voice == &quot;*garaj kapısını kapat&quot;) {digitalWrite(rel7, HIGH);} //Turn Off 7 Relay output</p><p>else if(voice == &quot;*perde kapat&quot;) {digitalWrite(rel8, HIGH);} //Turn Off 8 Relay output</p><p>else if(voice == &quot;*perdeyi kapat&quot;) {digitalWrite(rel8, HIGH);} //Turn Off 8 Relay output</p><p>else if(voice == &quot;*ferdi kapat&quot;) {digitalWrite(rel8, HIGH);} //Turn Off 8 Relay output</p><p>else if(voice == &quot;*ferdiyi kapat&quot;) {digitalWrite(rel8, HIGH);} //Turn Off 8 Relay output</p><p>//--------------*****************END USER DEFINED CODE*******************-------------//</p><p>//</p><p>//</p><p>//</p><p>//</p><p>//</p><p>//-------------------DO NOT EDIT AFTER THIS LINE------------------------// </p><p>voice=&quot;&quot;;}}</p><p>//-------------------DO NOT EDIT BEFORE THIS LINE-----------------------//</p>
<p>I tried some weeks to let it run on the arduino WiFi Shield. but it dosn&acute;t run well.</p><p>You have any idea?</p><p>Thanks</p>
<br><br>Hello sir Tcvella ,<br><br>First of all, sorry for my poor English!<br>I'm Sri lankan,so<br>I'm a beginner with Arduino, but this awesome Project is my favorite &amp; liked.<br>The gounda version worked for me very well (thank you Tcvella), but now i have a &quot;problem&quot; with the last iphone softweare,<br><br>I was looking for the any androide phone softwere, but I did not find iphone softweare them.Can somebody help me with a link, to download the iphone softweare.........manjulagraphic@gmail.com<br><br>Regard's from Manjula,<br><br><br>
<p>Very nice project! </p><p>i want to make a similar but i want to add an sd card to save there the html code </p><p>can anyone help?</p><p>thenks in advance</p>
<p>I have a question...<br>How would we do if we wanted to turn on and off a PC ?.<br>Both for one thing to the other , we need the relay a couple of seconds and then turn off.<br>Bye.</p>
<p>Hi iam narasimha from india, i saw your interesting code and started working on this i have successfully ported ethernet to wificlient using cc3200 TI and its wroking too.</p><p>Now iam facing a issue some times the web page not accessible even though iam using port forwarding concept for router.i have set the refresh rate as 10seconds some times it gets timeout how to fix it please suggest.</p><p>Narasimha jagirdar</p><p>+91-9901544165/+91-8892507761</p>
<p>The web page not accessible when i have tried to connect multiple clients to routers, that mean i flashed code in 5 devices , initially all are communicating but after 1hour or sometime some devices webpage notaccessible , why this timeout occuring, please suggest some fix.Tested on chrome,mozilla,safari browsers. same issue.</p><p>Best regards</p><p>narasimha</p>
<p>Hi Narasimhaj,</p><p>There was one person mentioned that it got stuck after a while running. He suggested that some IOs cannot be used as outputs, as they are used to drive the ethernet module. I had no time to check what is actually happening. So I dont know what is actually going on. There could be possible solutions such as close the connection if there is no response, or as a final workaround to restart the arduino.</p><p>If you would have some time to spare, check the above, and please reply if you find a solution.</p><p>Thanks</p><p>Claudio </p>
<p>Hi Claudio,</p><p> Thanks for the reply, i am working on it,currently iam suspecting the router which iam using ie TP-link as its going on standby after some time, i will update in this forum based on rigorous testing.</p><p>Thanks in advance</p><p>narasimhaj</p>
<p>can i implement this code with the enc28j60 module?</p>
Hello Mr. Vella .. I ask your help . I want to make the control 32 relays and 5 door monitoring sensor based on data from the web control arduino sketch . I want to control door sensor , if input = &lt; 2 volts then the &quot; safe &quot; . if input&gt; 2 then the &quot; danger &quot; . but the monitoring system is not connected to relay control systems . Thank you for your help.
<p>I could notfigure out what do you want to do. Please explain in moredetail.</p>
<p>32 control relays to keep using the ethernet web control like that you created in version 4.6, just add 5 sensors monitoring the door. door sensors using on / off switch, the first switch in place between + VCC 5 volts to pin A1, the second switch is placed between + VCC 5 volts to pin A2, as well until the fifth switch. when the door is opened, the pin goes high so that the show text &quot;safe&quot;, if the door is closed, the pin low value and appear the text &quot;danger&quot;. Thank you.</p>
<p>Ciao,<br>mi potreste aiutare ad inserire un sensore dht11 per leggere la temperatura?<br>Grazie<br>Walter</p>
Ciao Walter, dipende dal tipo del sensore. Io suggererei di cercare la datasheet sub web, e poi se il sensore varia la resistenza allora, predi un po di giacco vicino al sensore e prede anche u termometro vicino all giaccio, e misura la resistenza. Fa la stessa cosa con aqua calda. Questa tipo di scala e applicabile se il sensore e lineare. Se e logaritmico, allora e piu difficile.
Ol&aacute;, gostaria de saber qual &eacute; o endere&ccedil;o que coloco no navegador para ter acesso a p&aacute;gina. HTML que est&aacute; dentro do arduino?
Yes, you give the ip address on the arduino. Then from a browser on your mobile you type the ip address you inserted in the arduino.
<p>Hello,</p><p>First of all, sorry for my poor English!</p><p>I'm a beginner with Arduino, but this awesome Project is my favorite. </p><p>The gound version worked for me very well (thank you Tcvella), but now i have a &quot;problem&quot; with the last (Drewpalmer's version) upgrade..... </p><p>I was looking for the libraries to the translation, but I did not find all of them.</p><p>Can somebody help me with a link, to download the missing Libraries, or share with me a *.zip file, what implies the libraries..</p><p>Regard's from Hungary,</p><p>Tam&aacute;s</p>
Which libraries do you have missing?
Can somebody help me?
<p>Hello , how can I adapt this code for android ?</p>
It is html, thus should be fine. Graphics might vary a bit from browser to browser however.
<p>Hello, mr. Vella.<br>I loved this work and how available you are helping everyone out around here.<br>What is making me curious is how did you manage to transfer all the program to your arduino, once it's said that the ammount of variables is equivalent to 246% of my Mega capacity... Did you implemented a SD card or something?</p>
No it is saving on the arduino mega only. Eeprom is used to save the latest statuses in case of power failure, so that outputs remain to the last known status.
Ciao, ho tre sensori di temperatura mcp9700a, vorrei utilizzarli per indicare temp piano 1, temp piano 2 e temp ext, come posso adattare al tuo fantastico sketch, nel senso sia nella parte int che in quella della formula per fare leggere temperatura al termistore.<br>Ho scritto uno sketch dove posso regolare la temperatura e far accendere le elettrovalvole della caldaia per ogni singolo piano , e' possibile farlo sul tuo sketch? Mi aiuteresti ?<br>Grazie !!!!<br>Resto in attesa di una tua risposta.<br>
Ok...ci sono riuscito !!!<br>Mi manca solo la regolazione della temperatura e l'accensione delle elettrovalvole per piano...e poi una user e password per accedere! !!<br>Se puoi aiutarmi te ne sarei grato. <br>Intanto posto lo sketch, potrebbe essere utile !!!<br><br>Grazie e scusate se non scrivo in inglese !!!?
<p>How to turn on or off light without tablet or smartphone ????????</p>
<p>zoomx - Thank you, I know about it. But how to control without a browser? Need to add inputs for buttons. must be in control of the browser and the buttons.</p>
<p>I have messed around with this and adapted it to my needs I added code for buttons here is an example of what I did. It might give you an idea of how to get started</p><p>// Controling relays with pusch buttons</p><p>// Relays </p><p>int Hall = 22;</p><p>int LivingRoom = 23;</p><p>int Balcony = 24;</p><p>int Kitchen = 25;</p><p>// Button Pins</p><p>int button1 = 38; // Hall light button</p><p>int button2 = 39; // Living Room light button</p><p>int button3 = 40; // Balcony light button</p><p>int button4 = 41; // Kitchen light button</p><p>// This remembers the buttons last state</p><p>boolean lastButton = LOW;</p><p>boolean currentButton = LOW;</p><p>boolean ledOn = false;</p><p>boolean lastButton2 = LOW;</p><p>boolean currentButton2 = LOW;</p><p>boolean ledOn2 = false;</p><p>boolean lastButton3 = LOW;</p><p>boolean currentButton3 = LOW;</p><p>boolean ledOn3 = false;</p><p>boolean lastButton4 = LOW;</p><p>boolean currentButton4 = LOW;</p><p>boolean ledOn4 = false;</p><p>void setup() {</p><p> // These are the relays conected to the lights</p><p> pinMode(Hall, OUTPUT); //pin selected to control</p><p> pinMode(LivingRoom, OUTPUT); //pin selected to control</p><p> pinMode(Balcony, OUTPUT); //pin selected to control</p><p> pinMode(Kitchen, OUTPUT); //pin selected to control</p><p> // These are the puch buttons the switch the lights on or off</p><p> pinMode(button1, INPUT);</p><p> pinMode(button2, INPUT);</p><p> pinMode(button3, INPUT);</p><p> pinMode(button4, INPUT);</p><p>}</p><p>// This part Debounces the buttons </p><p>// Button1 debounce</p><p>boolean debounce(boolean last)</p><p>{</p><p> boolean current = digitalRead(button1);</p><p> if (last != current)</p><p> {</p><p> delay(5);</p><p> current = digitalRead(button1);</p><p> }</p><p> return current;</p><p>}</p><p>// Button2 debounce</p><p>boolean debounce2(boolean last2)</p><p>{</p><p> boolean current2 = digitalRead(button2);</p><p> if (last2 != current2)</p><p> {</p><p> delay(5);</p><p> current2 = digitalRead(button2);</p><p> }</p><p> return current2;</p><p>}</p><p>// Button3 debounce</p><p>boolean debounce3(boolean last3)</p><p>{</p><p> boolean current3 = digitalRead(button3);</p><p> if (last3 != current3)</p><p> {</p><p> delay(5);</p><p> current3 = digitalRead(button3);</p><p> }</p><p> return current3;</p><p>}</p><p>// Button4 debounce</p><p>boolean debounce4(boolean last4)</p><p>{</p><p> boolean current4 = digitalRead(button4);</p><p> if (last4 != current4)</p><p> {</p><p> delay(5);</p><p> current4 = digitalRead(button4);</p><p> }</p><p> return current4;</p><p>}</p><p>void loop() {</p><p>// And here is where the magic is done</p><p> // Start buttons</p><p> //button1 --------------------------------------------------------</p><p> currentButton = debounce(lastButton);</p><p> if (lastButton == LOW &amp;&amp; currentButton == HIGH)</p><p> {</p><p> ledOn = !ledOn;</p><p> }</p><p> lastButton = currentButton;</p><p> digitalWrite(Hall, ledOn);</p><p> //button2 --------------------------------------------------------</p><p> currentButton2 = debounce2(lastButton2);</p><p> if (lastButton2 == LOW &amp;&amp; currentButton2 == HIGH)</p><p> {</p><p> ledOn2 = !ledOn2;</p><p> }</p><p> lastButton2 = currentButton2;</p><p> digitalWrite(LivingRoom, ledOn2);</p><p> //button3 --------------------------------------------------------</p><p> currentButton3 = debounce3(lastButton3);</p><p> if (lastButton3 == LOW &amp;&amp; currentButton3 == HIGH)</p><p> {</p><p> ledOn3 = !ledOn3;</p><p> }</p><p> lastButton3 = currentButton3;</p><p> digitalWrite(Balcony, ledOn3);</p><p> //button4 --------------------------------------------------------</p><p> currentButton4 = debounce4(lastButton4);</p><p> if (lastButton4 == LOW &amp;&amp; currentButton4 == HIGH)</p><p> {</p><p> ledOn4 = !ledOn4;</p><p> }</p><p> lastButton4 = currentButton4;</p><p> digitalWrite(Kitchen, ledOn4);</p><p>} </p>

About This Instructable

200,487 views

359 favorites

License:

More by tcvella: RegisterWrite - extending the outputs of Arduino/Microcontroller  with shift registers ATTINY85 - The smallest Arduino Ethernet Switching - with Arduino
Add instructable to: