Hi, new here. been trying to rewrite code to control 2 relays via web remote but not having much luck. Want second outputPin =7 and can rename 2nd relay to whatever... Code now is as follows:
// Web server for switching 2 relays
#include "etherShield.h"
#include "ETHER_28J60.h"
#include "avr/wdt.h"
int outputPin = 6;
int Led_1 = 4;
int Led_2 = 5;
int relayStatus;
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique for your network,
static uint8_t ip[4] = {10, 100, 2, 45}; // IP address for the webserver
static uint16_t port = 80; // Use port 80 - the standard for HTTP
ETHER_28J60 e;
void setup()
{
wdt_disable();
e.setup(mac, ip, port);
pinMode(outputPin, OUTPUT);
pinMode(Led_1, OUTPUT);
pinMode(Led_2, OUTPUT);
digitalWrite(outputPin, LOW);
digitalWrite(Led_1, LOW);
digitalWrite(Led_2, HIGH);
wdt_enable(WDTO_2S);
}
void loop()
{
char* params;
if (params = e.serviceRequest())
{
e.print("
Web Remote
");if (strcmp(params, "?led=on") == 0)
{
digitalWrite(outputPin, HIGH);
digitalWrite(Led_1, HIGH);
digitalWrite(Led_2, LOW);
e.print("RELAY1 IS ON");
}
else if (strcmp(params, "?led=off") == 0)
{
digitalWrite(outputPin, LOW);
digitalWrite(Led_1, LOW);
digitalWrite(Led_2, HIGH);
e.print("RELAY1 IS OFF");
}
else
{
relayStatus = digitalRead(outputPin);
if (relayStatus == LOW)
{
e.print("RELAY1 IS OFF");
}
else
{
e.print("RELAY1 IS ON");
}
//e.print("
secondary line of text after buttons
");}
e.respond();
}
wdt_reset();
}