hi
i am having problems controlling an Arduino A000110 4 RELAYS SHIELD, when i upload the code to the Arduino Uno3 all the relays latch together on the NO & NC & Common, I have had this working before with input from 4 Honeywell SS495A Hall sensors.
I am at a loss where the error in the code is.
I have included my code for reference, the code has worked before
int hallswitch1 = 2; //Pin for Hall switch PIN= 2
int hallswitch2 = 3; //Pin for Hall switch PIN= 3
int hallswitch3 = 5; //Pin for Hall switch PIN= 5
int hallswitch4 = 6; //Pin for Hall switch PIN= 6
int val1 = 0; //Integer for reading Hall status
int val2 = 0;
int val3 = 0;
int val4 = 0;
int RELAY1 = 4; // The socket number on the Arduino that the relay1 will go to. Socket 4
int RELAY2 = 7; // The socket number on the Arduino that the relay1 will go to. Socket 7
int RELAY3 = 8; // The socket number on the Arduino that the relay1 will go to. Socket 8
int RELAY4 = 12; // The socket number on the Arduino that the relay1 will go to. Socket 12
void setup()
{
pinMode(hallswitch1, INPUT);
pinMode (RELAY1, OUTPUT);
pinMode(hallswitch2, INPUT);
pinMode (RELAY2, OUTPUT);
pinMode(hallswitch3, INPUT);
pinMode (RELAY3, OUTPUT);
pinMode(hallswitch4, INPUT);
pinMode (RELAY4, OUTPUT);
}
void loop() {
val1 = digitalRead(hallswitch1); //Read Hall pin status
val2 = digitalRead(hallswitch2); //Read Hall pin status
val3 = digitalRead(hallswitch3); //Read Hall pin status
val4 = digitalRead(hallswitch4); //Read Hall pin status
if (val1 == HIGH) {digitalWrite(RELAY1, LOW);}
else {digitalWrite(RELAY1, HIGH);}
if (val2 == HIGH) {digitalWrite(RELAY2, LOW);}
else {digitalWrite(RELAY2, HIGH);}
if (val3 == HIGH) {digitalWrite(RELAY3, LOW);}
else {digitalWrite(RELAY3, HIGH);}
if (val4 == HIGH) {digitalWrite(RELAY4, LOW);}
else {digitalWrite(RELAY4, HIGH);}
}