#include <spi.h> #include <ethernet.h> #include <servo.h> #include<sd.h> Servo myservo; byte mac[] ={0xDE, 0xAD, 0xBB, 0xEF, 0xFE, 0xED}; IPAddress ip(10,150,40,84); IPAddress gateway(10,150,40,1); IPAddress subnet(255,255,255,0); EthernetServer server(80); File webFile; int pos =10; String redString; void setup(){ myservo.attach(9); myservo.write(pos); Serial.begin(9600); pinMode(4,OUTPUT); Ethernet.begin(mac,ip,gateway,subnet); Serial.print("My Ip is : "); Serial.println(ip); server.begin(); //Init SD Card if(!SD.begin(4)){ Serial.println("ERROR - Initialization Failed!"); return; } Serial.println("SUCCESS -SD card Initialized."); if(!SD.exists("securino.htm")){ Serial.println("ERROR - Can't find securino.html"); }else{ Serial.println("SUCCESS - Found securino.html."); } } void loop(){ EthernetClient client = server.available(); // try to get a client if(client){ // got a client boolean currentLineIsBlank = true; while(client.connected()){ if(client.available()){// client data avail to read char c = client.read();// read 1 byte char from client // last line of client req. is blank and ends with \n // respond to client only after last line recieved if(redString.length()<100){ redString+=c; } if(c="\n" && currentLineIsBlank){ Serial.println(redString); // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type:text/html"); client.println("Connenction:close"); client.println(); // send Web page webFile = SD.open("securino.htm");//open webpage if(webFile){ while(webFile.available()){ client.write(webFile.read());// send webpage to client } webFile.close(); } break; if(redString.indexOf("?turnlft")>0){ // PROBLEM HERE **** pos = pos -10; myservo.write(pos); } if(redString.indexOf("?turnrght")>0){ // AND HERE **** pos = pos +10; myservo.write(pos); } redString =""; } //every line of text recieved from client ends with \r\n if(c=='\n'){ //last char on line of recieved text //starting new line with next character read currentLineIsBlank = true; } else if(c!='\r'){ //a text character was reciever from client currentLineIsBlank = false; } } } delay(1); // give the browser time to recieve the data client.stop(); } } <pre lang="c++"> and Here is the HTML Code, I Think the Problem lies Here Could you Help me This are the Two Link i used to Control the Motor .......... <a href="\"/?turnlft\"\"">Turn Left</a> <a href="\"/?turnrght\"\"">Turn Right</a>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)