1#include <Ethernet.h>
2#include<SPI.h>
3
4//CHANGE MAC ADRESS FROM YOUR STICKER ON THE MODULE!!!!!!!!!!
5byte mac[] = {0011, 002B, 003C, 004D, 005E, 0066}; //Define your mac address
6//CHANGE MAC ADRESS FROM YOUR STICKER ON THE MODULE!!!!!!!!!!
7EthernetServer serve = EthernetServer(55); //Create a server which listens on port 55
8
9
10void setup()
11{
12 Serial.begin(9600);
13 if(Ethernet.begin(mac) == 0)
14 {
15 Serial.println("Configuration failed");
16 return;
17 }
18 else
19 {
20 Serial.print("Arduino IP:"); //Displays your Arduino's local IP address
21 Serial.println(Ethernet.localIP());
22 }
23 serve.begin();
24 Serial.println("Server Running");
25}
26
27void loop()
28{
29 Serial.println("Waiting For Client Connection");
30 EthernetClient client = serve.available(); //Looks for incoming client connections
31 if(client)
32 {
33 Serial.print("Connected to client: ");
34 while(client.available())
35 {
36 char c = client.read();
37 Serial.print(c);
38 }
39 if(client.connected())
40 {
41 Serial.println("Webpage Sent To Client"); //Delivers a web page to the client
42 client.println("HTTP/1.1 200 OK");
43 client.println("Content-Type: text/html\n");
44 client.println("<center><h1>Connected To Your Arduino</h1></center>");
45 client.println("<center><h2>Hello John</h2></center>");
46 }
47 delay(8);
48 client.stop(); //Closes the client connection
49 Serial.println("Disconnected from client");
50 }
51 delay(1500);
52}