Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Relays working opposite

Hi. 

I have the yieldbuddy up and running, although I am missing a few components. I dont have the level converter, so I am running trough the USB.
The time schedules ar not working, probably because I dont have an RTC. 
One of the issues I am working on now is that relay 1>5 is working opposit of web interface. 
I found this in the relay_functions.ino:
void turnRelay(int Relay_num, int TurnOnOff){
  int Relay_Pin[6] = {
    Relay1_Pin, Relay2_Pin, Relay3_Pin, Relay4_Pin, Relay5_Pin, Relay6_Pin  };

  if (Relay_num < 6) {
    //Relay Board works opposite (Low/High) (Relays 1 - 5)
    if (TurnOnOff == 1) {
      digitalWrite(Relay_Pin[Relay_num - 1], LOW);
    }

    if(TurnOnOff == 0) {
      digitalWrite(Relay_Pin[Relay_num - 1], HIGH);      
    }
  }
   else if (Relay_num == 6) {
    //SSR relay works as expected (High/Low) (Relay 6)
    if (TurnOnOff == 1) {
      digitalWrite(Relay_Pin[Relay_num - 1], HIGH);  
    }

    if(TurnOnOff == 0) {
      digitalWrite(Relay_Pin[Relay_num - 1], LOW);      
    }
  }
  sendRelayMessages(); // (through serial)

Tried to swap the LOW an HIGH in the first function, but then i got no response at all.
For the record, relay 6 is working fine.

Does anyone have any idea?


Comments

  • edited February 2015
    Since relay 6 is working, I would just comment out the unneeded code like so:

    void turnRelay(int Relay_num, int TurnOnOff){
    int Relay_Pin[6] = {
    Relay1_Pin, Relay2_Pin, Relay3_Pin, Relay4_Pin, Relay5_Pin, Relay6_Pin };

    /*
    if (Relay_num < 6) {
    //Relay Board works opposite (Low/High) (Relays 1 - 5)
    if (TurnOnOff == 1) {
    digitalWrite(Relay_Pin[Relay_num - 1], LOW);
    }

    if(TurnOnOff == 0) {
    digitalWrite(Relay_Pin[Relay_num - 1], HIGH);
    }
    }
    else if (Relay_num == 6) {
    */
    //SSR relay works as expected (High/Low) (Relay 6)
    if (TurnOnOff == 1) {
    digitalWrite(Relay_Pin[Relay_num - 1], HIGH);
    }

    if(TurnOnOff == 0) {
    digitalWrite(Relay_Pin[Relay_num - 1], LOW);
    }
    //}
    sendRelayMessages(); // (through serial)
Sign In or Register to comment.