Hey Arudinio Gurus
I am trying to use an ethernet shield and a 4 relay shield with an UnoR3 all stacked together. They all fit nicely together with the headers. I previously wrote a sketch for the ethernet shield and was able to control relays with it but the hardware was messy. I wanted to use the 4 relay shield from arduino so it would look nicer.
I started writing a quick test sketch for the relay board and was able to turn relays 1,2,3 and 4 on for one second each. After testing that, I added the preliminary ethernet part of the sketch but hit a roadblock when I added the command :
Ethernet.begin(mac, ip);
This apparently disabled the signal for relay coil 4 which is controlled by pin 12. I am not able to choose what pins to use being the relay shield has pins 4,7,8 and 12 as the power signals for the relays.
Something in that command affected relay 4 (pin 12). My code works ok if I delete that command. Of course I need that command to continue setting up the ethernet shield.
Any help would be great.
Thanks guys.
Darren
// relay board 1st project
// Setting up the ethernet shield
#include <SPI.h>
#include <Ethernet.h> // Initialize the libraries.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //I left the MAC address and IP address blank.
byte ip[] = { 192, 168, 2, 251 }; // You will want to fill these in with your MAC and IP address.
EthernetServer server(80); // Assigning the port forwarded number. It's almost always 80.
String readString; // We will be using strings to keep track of things.
//*****************************************************************************************************************
const int RELAYCOIL1 = 4;
const int RELAYCOIL2 = 7;
const int RELAYCOIL3 = 8;
const int RELAYCOIL4 = 12;
void setup() {
// put your setup code here, to run once:
pinMode (RELAYCOIL1, OUTPUT); //sets the digital pin #4 as an output to power the coil of relay 1
pinMode (RELAYCOIL2, OUTPUT); //sets the digital pin #7 as an output to power the coil of relay 2
pinMode (RELAYCOIL3, OUTPUT); //sets the digital pin #8 as an output to power the coil of relay 3
pinMode (RELAYCOIL4, OUTPUT); //sets the digital pin #12 as an output to power the coil of relay 4
Ethernet.begin(mac, ip);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite (RELAYCOIL1, HIGH); //powers relay 1
delay (1000); //waits for 1 second
digitalWrite (RELAYCOIL1, LOW); //powers down relay 1
delay (500); //waits for half second
digitalWrite (RELAYCOIL2, HIGH); //powers relay 2
delay (1000); //waits for 1 second
digitalWrite (RELAYCOIL2, LOW); //powers down relay 2
delay (500); //waits for half second
digitalWrite (RELAYCOIL3, HIGH); //powers relay 3
delay (1000); //waits for 1 second
digitalWrite (RELAYCOIL3, LOW); //powers down relay 3
delay (500); //waits for half second
digitalWrite (RELAYCOIL4, HIGH); //powers relay 4
delay (1000); //waits for 1 second
digitalWrite (RELAYCOIL4, LOW); //powers down relay 4
delay (500); //waits for half second
}