Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet.h>
- byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
- byte gateway[] = { 192, 168, 0,1};
- byte subnet[] = { 255, 255, 255, 0 };
- IPAddress ip(192, 168, 0, 100);
- EthernetServer server(80);
- void setup()
- {
- Ethernet.begin(mac, ip,gateway,subnet);
- server.begin();
- }
- void loop()
- {
- EthernetClient client = server.available();
- if (client) { // got client?
- boolean currentLineIsBlank = true;
- while (client.connected()) {
- if (client.available()) { // client data available to read
- char c = client.read(); // read 1 byte (character) from client
- // last line of client request is blank and ends with \n
- // respond to client only after last line received
- if (c == '\n' && currentLineIsBlank) {
- // send a standard http response header
- client.println("HTTP/1.1 200 OK");
- client.println("Content-Type: text/html");
- client.println("Connection: close");
- client.println();
- // send web page
- client.println("<!DOCTYPE html>");
- client.println("<html>");
- client.println("<head>");
- client.println("<meta charset=utf-8>");
- client.println("<body bgcolor=black>");
- client.println("<font color=white>");
- client.println("<center><title>Protótipo GPS</title><center>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("</head>");
- client.println("<body>");
- client.println("<h1>PROTOTIPO GPS ARDUINO!</h1>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("<h3><p>Protótipo de GPS com tecnologias Arduino e Google API </p></h3>");
- client.println("<br>");
- client.println("<br>");
- client.println("<br>");
- client.println("<button><a href=http://localhost/index2.html/>CLIQUE AQUI PARA ACESSO AO GPS</a></button>");
- // client.println("<br><input type=\button\" value=\GPS\" onClick=\"window.location.href=\http://localhost/index2.html>");
- client.println("</body>");
- client.println("</html>");
- break;
- }
- // every line of text received from the client ends with \r\n
- if (c == '\n') {
- // last character on line of received text
- // starting new line with next character read
- currentLineIsBlank = true;
- }
- else if (c != '\r') {
- // a text character was received from client
- currentLineIsBlank = false;
- }
- } // end if (client.available())
- } // end while (client.connected())
- delay(1); // give the web browser time to receive the data
- client.stop(); // close the connection
- } // end if (client)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement