I have been working on the zoomkat code that he sent me. it's a great code and my problem is that I can have it work with 4 Button relay, but it does not work for 7 relays. to be correct thought, that when I add 7 relay code for the webpage the relays or LEDs do not response. but if I leave it with only 4 LED and relays it works just fine.
I have included the 1st code that is for 4 LEDs or relays, which works just fine, but the 2nd one that is for 7 relays/LEDs but none of them response. please look and see what I"m missing.
1st 4 LED code:
//zoomkat 12-08-12
//get submit box code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html or use a '
//address will look like http://192.168.1.70:80 when submited
//for use with W5100 based ethernet shields
//note that the below bug fix may be required
// Google Code Archive - Long-term storage for Google Code Project Hosting.
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 70 }; // ip in lan
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(){
pinMode(5, OUTPUT); //pin selected to control
pinMode(6, OUTPUT); //pin selected to control
pinMode(7, OUTPUT); //pin selected to control
pinMode(8, OUTPUT); //pin selected to control
//start Ethernet
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600);
Serial.println("server text box test1"); // 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); //see what was captured
//now output HTML data header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("");
client.println("");
client.println("");
client.println("");
client.println("JAVA Page");
client.println("");
client.println("");
client.println("
JAVA
");client.println("
");
client.println("
");
client.println(""); //uses IP/port of web page
client.println("Enter Code:
");
client.println("
");
client.print("<input type=submit value='5 ON' style=width:100px;height:45px onClick=location.href='/?on8;'>");
client.print("<input type=submit value='5 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>");
client.println("
");
client.print("<input type=submit value='6 ON' style=width:100px;height:45px onClick=location.href='/?on8;'>");
client.print("<input type=submit value='6 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>");
client.println("
");
client.print("<input type=submit value='7 ON' style=width:100px;height:45px onClick=location.href='/?on8;'>");
client.print("<input type=submit value='7 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>");
client.println("
");
client.print("<input type=submit value='8 ON' style=width:100px;height:45px onClick=location.href='/?on8;'>");
client.print("<input type=submit value='8 OFF' style=width:100px;height:45px onClick=location.href='/?off9;'>");
client.println("
");
client.println("");
client.println("");
client.println("");
delay(1);
//stopping client
client.stop();
/////////////////////
if(readString.indexOf("5") >0)//checks for on
{
digitalWrite(5, HIGH); // set pin 5 high
Serial.println("Led On");
}
if(readString.indexOf("50") >0)//checks for off
{
digitalWrite(5, LOW); // set pin 5 low
Serial.println("Led Off");
}
if(readString.indexOf("6") >0)//checks for on
{
digitalWrite(6, HIGH); // set pin 6 high
Serial.println("Led 6 On");
}
if(readString.indexOf("60") >0)//checks for off
{
digitalWrite(6, LOW); // set pin 6 low
Serial.println("Led 6 Off");
}
if(readString.indexOf("7") >0)//checks for on
{
digitalWrite(7, HIGH); // set pin 7 high
Serial.println("Led On");
}
if(readString.indexOf("70") >0)//checks for off
{
digitalWrite(7, LOW); // set pin 7 low
Serial.println("Led Off");
}
if(readString.indexOf("8") >0)//checks for on
{
digitalWrite(8, HIGH); // set pin 8 high
Serial.println("Led On");
}
if(readString.indexOf("80") >0)//checks for off
{
digitalWrite(8, LOW); // set pin 8 low
Serial.println("Led Off");
}
//clearing string for next read
readString="";
}
}
}
}
}