#include #include #include int printer = 4; Servo microservo; int pos = 0; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 178 }; // ip in lan (that's what you need to use in your browser. ("192.168.1.178") byte gateway[] = { 192, 168, 1, 1 }; // internet access via router byte subnet[] = { 255, 255, 255, 0 }; //subnet mask EthernetServer server(80); //server port String readString; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } pinMode(printer, OUTPUT); microservo.attach(7); // start the Ethernet connection and the server: Ethernet.begin(mac, ip, gateway, subnet); server.begin(); Serial.print("server is at "); Serial.println(Ethernet.localIP()); } void loop() { // Create a client connection EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read(); //read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } //if HTTP request has ended if (c == '\n') { Serial.println(readString); //print to serial monitor for debuging client.println("HTTP/1.1 200 OK"); //send new page client.println("Content-Type: text/html"); client.println(); client.println(""); client.println(""); client.println(""); client.println(""); client.println(""); client.println("Vedant Naik's Wifi printer online switch"); client.println(""); client.println(""); client.println("

Vedant K Naik Printer switch 3.0

"); client.println("
"); client.println("
"); client.println("

Sponsored by Kalpesh Naik & Bijal Naik

"); client.println("
"); client.println("

for HP printer Conected on SSID-KDNHome+

"); client.println("Turn On Printer of Vedant Naik"); client.println("Turn Off Printer of Vedant Naik
"); client.println("
"); client.println("
"); client.println("

DO NOT COPPY THIS CODE STRICT ACTION WOULD BE TAKEN WHO WOULD COPPY THIS CODE

"); client.println("
"); client.println("

REGARDS VEDANT KALPESH NAIK (OWNER OF PRINTER AND CREATOR)

"); client.println("

Created by Vedant Kalpesh Naik (student of Navrachana Vidyani Vidyalaya)

"); client.println("
"); client.println(""); client.println(""); delay(1); //stopping client client.stop(); //controls the Arduino if you press the buttons if (readString.indexOf("?button1on") >0){ digitalWrite(printer, HIGH); } if (readString.indexOf("?button1off") >0){ digitalWrite(printer, LOW); } //clearing string for next read readString=""; } } } } }