Below is some continous rotation servo test code I made that I use with the w5100 shield. Bottom is the html web page I use on my desktop to control the servos. Fairly simple setup for doing some testing basic testing.
//zoomkat 10-22-10
//routerbot code
//for use with IDE 0021
//open serial monitor to see what the arduino receives
//use a url like below in a browser to test
// http://192.168.1.102:84/?-1450-1550
#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
Server server(84); //server port
String readString, servo1, servo2;
Servo myservo1; // create servo object to control a servo
Servo myservo2;
//////////////////////
void setup(){
//start Ethernet
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600);
myservo1.attach(7);
myservo2.attach(6);
Serial.println("bot21"); // so I can keep track of what is loaded
}
void loop(){
// Create a client connection
Client 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;
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.println(readString);
//readString looks like "GET /?-1500-1500 HTTP/1.1"
if (readString.length() >0) {
Serial.println(readString);
servo1 = readString.substring(7, 11);
servo2 = readString.substring(12, 16);
Serial.println(servo1);
Serial.println(servo2);
int n1;
int n2;
char carray1[6];
servo1.toCharArray(carray1, sizeof(carray1));
n1 = atoi(carray1);
char carray2[6];
servo2.toCharArray(carray2, sizeof(carray2));
n2 = atoi(carray2);
myservo1.writeMicroseconds(n1);
myservo2.writeMicroseconds(n2);
//myservo.write(n);
readString="";
}
///////////////////
//now output HTML data header
client.println("HTTP/1.1 204 Zoomkat");
client.println();
client.println();
delay(1);
//stopping client
client.stop();
/////////////////////
//clearing string for next read
readString="";
}
}
}
}
}
copy, paste in notepad, and save as test.htm on the desktop. OK the windows warnings generated when opened by double clicking to open.
<HTML>
<HEAD>
<H3>Zoomkat's Routerbot
Web Control Page</H3>
<TITLE>Zoomkat's Routerbot Control Page</TITLE>
</HEAD>
<BODY>
Foward-*Stop*-Reverse
<a href="http://192.168.1.102:84/?-1000-2000" target="inlineframe">F-F</a>|
<a href="http://192.168.1.102:84/?-1450-1550" target="inlineframe">S-F</a>|
<a href="http://192.168.1.102:84/?-1500-1500" target="inlineframe">*-Stop-*</a>|
<a href="http://192.168.1.102:84/?-1550-1450" target="inlineframe">S-R</a>|
<a href="http://192.168.1.102:84/?-2000-1000" target="inlineframe">F-R</a>|
Turn-L-*Stop*-Turn-R
<a href="http://192.168.1.102:84/?-1000-1000" target="inlineframe">F-L</a>|
<a href="http://192.168.1.102:84/?-1450-1450" target="inlineframe">S-L</a>|
<a href="http://192.168.1.102:84/?-1500-1500" target="inlineframe">*-Stop-*</a>|
<a href="http://192.168.1.102:84/?-1550-1550" target="inlineframe">S-R</a>|
<a href="http://192.168.1.102:84/?-2000-2000" target="inlineframe">F-R</a>|
<IFRAME name=inlineframe
src="res://D:\WINDOWS\System32\shdoclc.dll/dnserror.htm" width=1
height=1> this will hold the html answer of the moves
</IFRAME>
</body>
</html>