daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Jun 11th, 2015 251 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include
  2. #include
  3.  
  4. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  5. byte ip[] = { 192, 168, 0, 168 };
  6.      
  7. EthernetServer server(80);
  8.  
  9. String readString;
  10. int Pin6 = 6;
  11. int Pin7 = 7;
  12.  
  13. void setup() {
  14.  
  15.   pinMode(Pin6, OUTPUT);
  16.   pinMode(Pin7, OUTPUT);
  17.   Ethernet.begin(mac, ip);
  18.   server.begin();
  19. }
  20.  
  21. void loop() {
  22.   EthernetClient client = server.available();
  23.   if (client) {
  24.     while (client.connected()) {
  25.       if (client.available()) {
  26.         char c = client.read();
  27.  
  28.         if (readString.length() < 100) {
  29.           readString += c;            
  30.         }
  31.  
  32.         if (c == '\n') {
  33.           client.println("HTTP/1.1 200 OK");
  34.           client.println("Content-Type: text/html");
  35.           client.println();
  36.            
  37.           client.println("");
  38.           client.println("");
  39.           client.println("modulo rele pela web");
  40.           client.println("");
  41.           client.println("");
  42.           client.println("");
  43.           client.println("");
  44.            
  45.           client.println("<a>LIGAR - Bomba 1</a>");
  46.           client.println("");
  47.           client.println("<a>DESLIGAR - Bomba 1</a>");
  48.          
  49.           client.println("");
  50.        
  51.           client.println("<a>LIGAR - Bomba 2</a>");
  52.           client.println("");
  53.           client.println("<a>DESLIGAR - Bomba 2</a>");    
  54.            
  55.           client.println("");
  56.           client.println("");
  57.          
  58.           delay(1);
  59.           client.stop();
  60.          
  61.           if(readString.indexOf("?rele6on") > 0)
  62.           {
  63.             digitalWrite(Pin6, HIGH);
  64.           }
  65.           else {
  66.             if(readString.indexOf("?rele6off") > 0)
  67.             {
  68.               digitalWrite(Pin6, LOW);
  69.             }
  70.                              
  71.             if(readString.indexOf("?rele7on") > 0)
  72.             {
  73.               digitalWrite(Pin7, HIGH);
  74.             }
  75.             else {
  76.               if(readString.indexOf("?rele7off") > 0)
  77.               {
  78.                 digitalWrite(Pin7, LOW);
  79.               }
  80.             }
  81.             readString="";    
  82.           }
  83.         }
  84.       }
  85.     }
  86.   }
  87. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand