Advertisement
Guest User

Untitled

a guest
Jun 28th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <Ethernet.h>
  3.  
  4.  
  5. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  6. byte gateway[] = { 192, 168, 0,1};
  7. byte subnet[] = { 255, 255, 255, 0 };
  8. IPAddress ip(192, 168, 0, 100);
  9. EthernetServer server(80);
  10.  
  11. void setup()
  12. {
  13. Ethernet.begin(mac, ip,gateway,subnet);
  14. server.begin();
  15. }
  16. void loop()
  17. {
  18. EthernetClient client = server.available();
  19.  
  20. if (client) { // got client?
  21. boolean currentLineIsBlank = true;
  22. while (client.connected()) {
  23. if (client.available()) { // client data available to read
  24. char c = client.read(); // read 1 byte (character) from client
  25. // last line of client request is blank and ends with \n
  26. // respond to client only after last line received
  27.  
  28. if (c == '\n' && currentLineIsBlank) {
  29. // send a standard http response header
  30. client.println("HTTP/1.1 200 OK");
  31. client.println("Content-Type: text/html");
  32. client.println("Connection: close");
  33. client.println();
  34. // send web page
  35. client.println("<!DOCTYPE html>");
  36. client.println("<html>");
  37. client.println("<head>");
  38. client.println("<meta charset=utf-8>");
  39. client.println("<body bgcolor=black>");
  40. client.println("<font color=white>");
  41. client.println("<center><title>Protótipo GPS</title><center>");
  42. client.println("<br>");
  43. client.println("<br>");
  44. client.println("<br>");
  45. client.println("<br>");
  46. client.println("<br>");
  47. client.println("<br>");
  48. client.println("<br>");
  49. client.println("</head>");
  50. client.println("<body>");
  51. client.println("<h1>PROTOTIPO GPS ARDUINO!</h1>");
  52. client.println("<br>");
  53. client.println("<br>");
  54. client.println("<br>");
  55. client.println("<br>");
  56. client.println("<h3><p>Protótipo de GPS com tecnologias Arduino e Google API </p></h3>");
  57. client.println("<br>");
  58. client.println("<br>");
  59. client.println("<br>");
  60. client.println("<button><a href=http://localhost/index2.html/>CLIQUE AQUI PARA ACESSO AO GPS</a></button>");
  61. // client.println("<br><input type=\button\" value=\GPS\" onClick=\"window.location.href=\http://localhost/index2.html>");
  62.  
  63.  
  64. client.println("</body>");
  65. client.println("</html>");
  66. break;
  67. }
  68.  
  69. // every line of text received from the client ends with \r\n
  70. if (c == '\n') {
  71. // last character on line of received text
  72. // starting new line with next character read
  73. currentLineIsBlank = true;
  74. }
  75. else if (c != '\r') {
  76. // a text character was received from client
  77. currentLineIsBlank = false;
  78. }
  79. } // end if (client.available())
  80. } // end while (client.connected())
  81. delay(1); // give the web browser time to receive the data
  82. client.stop(); // close the connection
  83. } // end if (client)
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement