/*---H-bridge Pin assignments for this code..... First H-Bridge ----- Arduino ____________ Iris (+) IN1 ---- 22 Iris (-) 1N2 ---- 23 Zoom (+) IN3 ---- 24 Zoom (-) IN4 ---- 25 Second H-Bridge ---- Arduino ____________ Focus (+) IN3 ---- 26 Focus (-) IN4 ---- 27 --*/ #include //install libraries for the ethernet #include #include #include #include #include #include byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xD3, 0x7B}; // <-Set your ethernet card's MAC address. this should be ok. byte ip[] = { 10,16,176,223 }; //<--Replace with your ip address EthernetServer server(80); //<--Create a Web Server. WWW runs on port 80 by default. String camString; //Create a string to use for buttons String message = ""; //same here void setup(){ Serial.begin(9600); for (int i=2; i<53; i++){ //quickly make all pins outputs pinMode(i, OUTPUT); digitalWrite (i,LOW); // and set them low } Ethernet.begin( mac,ip); //<-- start the ethernet card server.begin(); //<-- start the web server } void loop(){ EthernetClient client = server.available(); //<-- start listening for someone to talk to us if (client) { Serial.println("connection"); while (client.connected()) { if (client.available()) { char c = client.read(); if (camString.length() < 100) { camString += c; } if (c == '\n') { // <-someone knocked. lets show them a webpage full of buttons! client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); //client.printlnln(); client.println(F("")); client.println(F("")); client.println(F("Arduino CamControl")); client.println(F("")); client.println(F("")); client.println(F("Lens Control
")); client.println(F("")); client.println(F("")); client.println(F("")); client.println(F("")); client.println(F("")); client.println(F("")); client.println(F("")); client.println(F("
Camera Menu Control
")); client.println(""); client.println(""); delay(1); client.stop(); // The block below watches for button presses and applies the correct actions....... if(camString.substring(6,12) == "zoomin") //<-- Zoom in button pressed. { zoomin(); //<-- jump to routine that sends appropriate commands to motors } if(camString.substring(6,13) == "zoomout") //<-- Same as above but for Zoom Out { zoomout(); } if(camString.substring(6,15) == "zoominall") //<--zooms in all the way { zoominall(); } if(camString.substring(6,16) == "zoomoutall") //<--zooms out all the way { zoomoutall(); } if(camString.substring(6,14) == "irisopen") { irisopen(); } if(camString.substring(6,15) == "irisclose") { irisclose(); } if(camString.substring(6,13) == "focusin") { focusin(); } if(camString.substring(6,14) == "focusout") { focusout(); } if(camString.substring(6,15) == "focusin20") { focusin20(); } if(camString.substring(6,16) == "focusout20") { focusout20(); } camString=""; //<-- this clears the command string so it doesnt keep doing the same command over and over! } } } } } // This block holds all the routines that control what the pins do when buttons are pressed. void zoomin() { digitalWrite(24, HIGH); digitalWrite(25, LOW); delay(100); digitalWrite(24, LOW); digitalWrite(25, LOW); } void zoomoutall() { digitalWrite(24, LOW); digitalWrite(25, HIGH); delay(3000); digitalWrite(24, LOW); digitalWrite(25, LOW); } void zoominall() { digitalWrite(24, HIGH); digitalWrite(25, LOW); delay(3000); digitalWrite(24, LOW); digitalWrite(25, LOW); } void zoomout() { digitalWrite(24, LOW); digitalWrite(25, HIGH); delay(100); digitalWrite(24, LOW); digitalWrite(25, LOW); } void irisopen() { digitalWrite(22, HIGH); digitalWrite(23, LOW); delay(30); digitalWrite(22, LOW); digitalWrite(23, LOW); } void irisclose() { digitalWrite(22, LOW); digitalWrite(23, HIGH); delay(30); digitalWrite(22, LOW); digitalWrite(23, LOW); } void focusin() { digitalWrite(26, HIGH); digitalWrite(27, LOW); delay(30); digitalWrite(26, LOW); digitalWrite(27, LOW); } void focusin20() { digitalWrite(26, HIGH); digitalWrite(27, LOW); delay(700); digitalWrite(26, LOW); digitalWrite(27, LOW); } void focusout() { digitalWrite(26, LOW); digitalWrite(27, HIGH); delay(30); digitalWrite(26, LOW); digitalWrite(27, LOW); } void focusout20() { digitalWrite(26, LOW); digitalWrite(27, HIGH); delay(700); digitalWrite(26, LOW); digitalWrite(27, LOW); }