Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <String.h>
- #include <Ethernet.h>
- byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x9B, 0x36 };
- byte ip[] = { 192, 168, 0, 91 };
- EthernetServer server(8090);
- String readString = String(30);
- void setup() {
- Ethernet.begin(mac, ip);
- }
- void loop() {
- EthernetClient client = server.available();
- if(client)
- {
- while(client.connected())
- {
- if(client.available())
- {
- char c = client.read();
- if(readString.length() < 30) {
- readString += (c);
- }
- if(c == '\n')
- {
- // cabeçalho http padrão
- client.println("HTTP/1.1 200 OK");
- client.println("Content-Type: text/html");
- client.println();
- client.println("<!doctype html>");
- client.println("<html>");
- client.println("<head>");
- client.println("<title>Exemplo Link</title>");
- client.println("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
- client.println("<meta charset=\"utf-8\">");
- client.println("</head>");
- client.println("<body>");
- client.println("<center>");
- client.println("<h1>Exemplo de link - Arduino e Ethernet</h1>");
- // no html seria assim: <a href="https://www.google.com.br">Acesse o Google</a>
- // então no arduino fica assim
- client.println("<a href=\"https://www.youtube.com/user/TecnoEduardo\">Visite o link aqui!</a>");
- client.println("</center>");
- client.println("</body>");
- client.println("</html>");
- readString = "";
- client.stop();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement