Hi everybody.
I found a sketch on the web to control a camera and send a hposition and a vposition to the arduino.
But the sketch was incomplete and I dont know how to use this datas...
When I send 100 and 200, the request is: http://192.168.0.177/?vpos=100&hpos=200
But how to use this values?
Thank you for your help.
Here is my code:
#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 177 }; // ip in lan
byte gateway[] = { 192, 168, 0, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString;
//////////////////////
void setup(){
pinMode(12, OUTPUT); //pin selected to control
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
myservo.write(90); //set initial servo position if desired
myservo.attach(7); //the pin for the servo co
//enable serial data print
Serial.begin(9600);
Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}
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("Arduino GET test page");
client.println("");
client.println("");
client.println("
Zoomkat's simple Arduino button
");client.print("");
client.println("");
client.println("");
client.println("");
client.println("Initial Vertical Position:
");
client.println("Initial Horizontal Position:
");
client.println("");
client.println("");
client.println("");
client.println("");
client.println("");
delay(1);
//stopping client
client.stop();
int a;int b;
///////////////////// control arduino pin
if(readString.indexOf("vpos") >0)//checks for on
{
Serial.println("I want to know the vpos value");
a='vpos';
Serial.println(a);//doesn' work....
}
if(readString.indexOf("hpos") >0)//checks for off
{
Serial.println("I want to know the hpos value");
b='vpos';
Serial.println(b);
}
//clearing string for next read
readString="";
}
}
}
}
}