Close
0%
0%

Run your Hunter or Rainbird via Arduino.

We decoded the protocols of Hunter and Railbird irrigation controllers.
I have uploaded the SOURCE CODE as an .rtf

Public Chat
Similar projects worth following
Please look in the files section of this project.

I have uploaded the Arduino Code to allow you to operate your Hunter and Rainbird controllers with an Arduino. Attach your arduino to a RPI and you're ready to run your old school irrigation controller from the cloud.


If it's hanging on the wall in your garage then The WATERKARMA dev board already owns it.

The thing that makes WATERKARMA special is that it offers full remote functionality of all the NAME BRAND irrigation controllers some of which are more than 15 years old. This is not a rain sensor circuit trick (I did that years ago).

Remotely Fire Zone 26 for 9 min or zone 3 for 2 min.

Most High End Commercial Grade Irrigation Controllers have more than 6, 8, or 12 zones.

This means that the user not only paid over $200 for their controller they more than likely paid an additional $200-$300 for expensive Zone Expansion Modules. How would you like to take a $500 piece of hardware off the wall in your garage and throw it in the TRASH??? It's NOT GONNA HAPPEN! How would you like to keep that controller and pay $100-$200 to convert it to a Cloud Based Algorithm Optimized Smart Controller that can be operated from a smart phone or computer??? Sounds like a no brainer to me. Since I've been a contractor working in the field for over 10 years I can say it would be infinitely easier to sell to a customer.

When WATERKARMA is combined with your project consumers won't have to drop more than $900 at the hardware store to purchase three 12 zone crap-io's and run 3 separate iPhone's with 3 separate Apple Id's if they have a system with 36 zones. No need to install, rewire and hang 3 separate controllers on their garage wall then have to buy an outlet splitter so they'll have somewhere to show off those 3 massive 24vAC Wall Warts.

If you have a two wire encoder/decoder irrigation controller than interfacing with that controller is a must.

THE WATERKARMA DEV BOARD IS FULLY COMPATIBLE WITH 2 WIRE ENCODER/DECODER SYSTEMS.

WATERKARMA CAN RUN AS MANY AS 200 ZONES ON A SINGLE EXISTING CONTROLLER.



Rich Text Format - 12.08 kB - 05/18/2021 at 00:27

Download

  • 1
    Step 1

    /*

    WK Arduino Software version 1-15-2015

    By: WATERKARMA

    Takes commands via serial port in this form: <S=_:Z=___:T=___:N=___>

    Sprinkler systems supported: Hunter, RainBird

    */

    #include <LiquidCrystal.h>

    //********************************************************

    const int pinSerialOut = 12;

    const int pinSerialIn = 13;

    const int BuzzerPos = A5;

    const int BuzzerNeg = A2;

    int varZone = 1;

    int varTimeOn = 1;

    int varTemp_int;

    char varCharRecover_char;

    unsigned long varMillisSave_ulong;

    byte varTemp_byte = 0;

    char varCharSerialRead;

    char charMessageSys;

    int intMessageZone;

    int intMessageTime;

    int intMessageNote;

    String varString = "";

    // Hunter fx Variables

    String varP0_String = "11111111010000000000000";

    String varP1_String = "00000000000010000000000000";

    String varP2_String = "00000000000010000000000000";

    String varP3_String = "00000000000010000000000000";

    String varP4_String = "001101110000011111110";

    // RB fx Variables

    const int timetiltrans = 215; //manchester encoding stuff time in uS

    const int timeaftertrans = 150; //manchester encoding stuff time in uS

    byte arrayOn_Byte[] = {245,245,245,28,4,57,0,1,5,67,B00011100};  //on command zone info in arrayOn_Byte[7]=zone and arrayOn_Byte[9]=zone+66

    byte arrayOff_Byte[] = {245,245,245,28,1,64,65,B00011100};  //off command regardles of zone

    //--------------------------------------------------------------------------------------------

    void setup()

      // Open Serial port

      Serial.begin(9600); 

      Serial.println("<Initialized>");

      // Pin 13 has an LED connected on most Arduino boards:

      //  pinMode(0, INPUT);

      //  pinMode(1, INPUT);

      //  pinMode(2, INPUT);

      pinMode(8, OUTPUT);

      pinMode(9, OUTPUT);

      pinMode(4, OUTPUT);

      pinMode(5, OUTPUT);

      pinMode(6, OUTPUT);

      pinMode(7, OUTPUT);

      pinMode(11, INPUT);

      pinMode(12, OUTPUT);

      digitalWrite(12, HIGH);

      pinMode(13, INPUT);

      //digitalWrite(13, HIGH); // Pull up

      pinMode(BuzzerNeg, OUTPUT);

      digitalWrite(BuzzerNeg, LOW);

      pinMode(BuzzerPos, OUTPUT);

      digitalWrite(BuzzerPos, LOW);

      digitalWrite(BuzzerPos, 1);

      delay(100);

      digitalWrite(BuzzerPos, 0);

      delay(200);

      digitalWrite(BuzzerPos, 1);

      delay(100);

      digitalWrite(BuzzerPos, 0);

      delay(200);

      digitalWrite(BuzzerPos, 1);

      delay(100);

      digitalWrite(BuzzerPos, 0);

      delay(1000);

    }

    //--------------------------------------------------------------------------------------------

    void loop()  { 

      while (Serial.available() > 0) Serial.read(); // Flush the serial receive buffer

      while (Serial.available() == 0)  delay(1);

      if (Serial.available() > 0)  {

        varMillisSave_ulong = millis();

        while ((Serial.available() < 23) && (millis() - varMillisSave_ulong < 250))  delay(1);

        if (Serial.available() < 23)  {

          Serial.println("<Timed Out - Message Short>");

        }

        else  {

          varString = "";

          for (int i=0; i < 23; i++)  {

            varCharSerialRead = Serial.read();

            varString += varCharSerialRead;

          }

          //Parse Message

          if (varString.indexOf('<') != 0)  Serial.println("Message Error - Begin Sentinel");

          else if (varString.indexOf('>') != 22)  Serial.println("Message Error - End Sentinel");

          else if (varString.charAt(1) != 'S')  Serial.println("Message Error - System Parameter");

          else if (varString.charAt(5) != 'Z')  Serial.println("Message Error - Zone Parameter");

          else if (varString.charAt(11) != 'T')  Serial.println("Message Error - Time Parameter");

          else if (varString.charAt(17) != 'N')  Serial.println("Message Error - Note Parameter");

          else  {

            //Passed all parameter checks

            charMessageSys = varString.charAt(3);

            intMessageZone = varString.substring(7,10).toInt();

            intMessageTime = varString.substring(13,16).toInt();

            intMessageNote = varString.substring(19,22).toInt();

            Serial.print("<Valid Message:S=");

            Serial.print(charMessageSys);

            Serial.print(":Z=");

            Serial.print(intMessageZone);

            Serial.print(":T=");

            Serial.print(intMessageTime);

            Serial.print(":N=");

            Serial.print(intMessageNote);

            Serial.println(">");

            if (charMessageSys == 'H')  {

              if (intMessageZone < 1)  varZone = 1;

              else if (intMessageZone > 48)  varZone = 48;

              else varZone = intMessageZone;

              if (intMessageTime < 0)  varTimeOn = 0;

              else if (intMessageTime > 90)  varTimeOn = 90;

              else varTimeOn = intMessageTime;

              fxPlayHunter();

            }

            if (charMessageSys == 'R')  {

              if (intMessageZone < 1)  varZone = 1;

              else if (intMessageZone > 48)  varZone = 48;

              else varZone = intMessageZone;

              if (intMessageTime < 0)  varTimeOn = 0;

              else if (intMessageTime > 1)  varTimeOn = 1;

              else varTimeOn = intMessageTime;

              fxPlayRB();

            }

            Serial.print("<Message Sent:S=");

            Serial.print(charMessageSys);

            Serial.print(":Z=");

            Serial.print(varZone);

            Serial.print(":T=");

            Serial.print(varTimeOn);

            Serial.println(">");

          }

        }

      }

      digitalWrite(A5, HIGH);

      delay(100);

      digitalWrite(A5, LOW);

    }

    //--------------------------------------------------------------------------------------------

    void fxPlayHunter()  {

      //Build message from the front starting with P0

      if (varZone < 13)  {  //Weird change in P0 but it only happens at the zone 12 to 13 transition, phew!

        varP0_String.setCharAt(9,'1');

        varP0_String.setCharAt(10,'0');

      }

      else  {

        varP0_String.setCharAt(9,'0');

        varP0_String.setCharAt(10,'1');

      }

      //P1 here

      varTemp_byte = varZone + 23;

      for (int i=0; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i,'0');

        else  varP1_String.setCharAt(i,'1');

      }

      for (int i=0; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 13,'0');

        else  varP1_String.setCharAt(i + 13,'1');

      }

      varTemp_byte = varTimeOn;

      for (int i=0; i <= 3; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 8,'0');

        else  varP1_String.setCharAt(i + 8,'1');

      }

      for (int i=4; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 21 - 4,'0');

        else  varP1_String.setCharAt(i + 21 - 4,'1');

      }

      //P2 here

      varTemp_byte = varZone + 35;

      for (int i=0; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i,'0');

        else  varP2_String.setCharAt(i,'1');

      }

      for (int i=0; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 13,'0');

        else  varP2_String.setCharAt(i + 13,'1');

      }

      varTemp_byte = varTimeOn;

      for (int i=0; i <= 3; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 8,'0');

        else  varP2_String.setCharAt(i + 8,'1');

      }

      for (int i=4; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 21 - 4,'0');

        else  varP2_String.setCharAt(i + 21 - 4,'1');

      }

      //P3 here

      varTemp_byte = varZone + 47;

      for (int i=0; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i,'0');

        else  varP3_String.setCharAt(i,'1');

      }

      for (int i=0; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 13,'0');

        else  varP3_String.setCharAt(i + 13,'1');

      }

      varTemp_byte = varTimeOn;

      for (int i=0; i <= 3; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 8,'0');

        else  varP3_String.setCharAt(i + 8,'1');

      }

      for (int i=4; i <= 6; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 21 - 4,'0');

        else  varP3_String.setCharAt(i + 21 - 4,'1');

      }

      //P4 here

      varTemp_byte = varZone - 1;

      for (int i=0; i <= 3; i++)  {

        if (bitRead(varTemp_byte,i) == 0)  varP4_String.setCharAt(i + 8,'0');

        else  varP4_String.setCharAt(i + 8,'1');

      }

      varString = "";

      varString = varP0_String + varP1_String + varP2_String + varP3_String + varP4_String;

      delay(150);

      digitalWrite(A5, HIGH);

      delay(100);

      digitalWrite(A5, LOW);

      digitalWrite(pinSerialOut, LOW);

      //Serial.print("L");

      delay(320);

      digitalWrite(pinSerialOut, HIGH);

      //Serial.print("H");

      delay(65);

      digitalWrite(pinSerialOut, LOW);

      //Serial.println("L");

      delayMicroseconds(900);

      varTemp_int = varString.length() - 1;

      for (int i=0; i <= varTemp_int; i++)  {

        varCharRecover_char = varString.charAt(i);

        //Serial.write(varCharRecover_char);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(225);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(225);

        if (varCharRecover_char == '0')  digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(1800);

      }

      digitalWrite(pinSerialOut, HIGH);

      //Serial.println("");

      //Serial.println("End");

    }

    void fxPlayRB()  {

      //Serial.print("Building ON message with zone: ");

      //Serial.println(varZone);

      arrayOn_Byte[7] = varZone;

      arrayOn_Byte[9] = varZone + 66;

      delay(150);

      digitalWrite(A5, HIGH);

      delay(100);

      digitalWrite(A5, LOW);

      if (varTimeOn == 1)  {  // Send ON message

        for (int ii=0; ii <= 9; ii++)  {

          for (int i=7; i >= 0; i--)  {

            if (bitRead(arrayOn_Byte[ii],i) == 1)  {

              digitalWrite(pinSerialOut, HIGH);

              delayMicroseconds(timetiltrans);

              digitalWrite(pinSerialOut, LOW);

              delayMicroseconds(timeaftertrans);

              //Serial.print("1");

            }

            else  {

              digitalWrite(pinSerialOut, LOW);

              delayMicroseconds(timetiltrans);

              digitalWrite(pinSerialOut, HIGH);

              delayMicroseconds(timeaftertrans);

              //Serial.print("0");

            }

          }

          //Serial.print(" ");

        }

        for (int i=7; i >= 1; i--)  {

          if (bitRead(arrayOn_Byte[10],i) == 1)  {

            digitalWrite(pinSerialOut, HIGH);

            delayMicroseconds(timetiltrans);

            digitalWrite(pinSerialOut, LOW);

            delayMicroseconds(timeaftertrans);

            //Serial.print("1");

          }

          else  {

            digitalWrite(pinSerialOut, LOW);

            delayMicroseconds(timetiltrans);

            digitalWrite(pinSerialOut, HIGH);

            delayMicroseconds(timeaftertrans);

            //Serial.print("0");

          }

        }

      }

      else  {  // Send OFF Message

        for (int ii=0; ii <= 6; ii++)  {

          for (int i=7; i >= 0; i--)  {

            if (bitRead(arrayOff_Byte[ii],i) == 1)  {

              digitalWrite(pinSerialOut, HIGH);

              delayMicroseconds(timetiltrans);

              digitalWrite(pinSerialOut, LOW);

              delayMicroseconds(timeaftertrans);

              //Serial.print("1");

            }

            else  {

              digitalWrite(pinSerialOut, LOW);

              delayMicroseconds(timetiltrans);

              digitalWrite(pinSerialOut, HIGH);

              delayMicroseconds(timeaftertrans);

              //Serial.print("0");

            }

          }

          //Serial.print(" ");

        }

        for (int i=7; i >= 1; i--)  {

          if (bitRead(arrayOff_Byte[7],i) == 1)  {

            digitalWrite(pinSerialOut, HIGH);

            delayMicroseconds(timetiltrans);

            digitalWrite(pinSerialOut, LOW);

            delayMicroseconds(timeaftertrans);

            //Serial.print("1");

          }

          else  {

            digitalWrite(pinSerialOut, LOW);

            delayMicroseconds(timetiltrans);

            digitalWrite(pinSerialOut, HIGH);

            delayMicroseconds(timeaftertrans);

            //Serial.print("0");

          }

        }

      }

      delayMicroseconds(timeaftertrans);

      digitalWrite(pinSerialOut, LOW);

      //Serial.println();

      //Serial.println("End");

    }

View all instructions

Enjoy this project?

Share

Discussions

Andrew wrote 13 hours ago point

Thanks for posting the code! It's too late for me as I have replaced the hardware (it's awful), but I really hope others can make use of this to improve what they have if they are still using it.

  Are you sure? yes | no

chadclick wrote 14 hours ago point

/*

WK Arduino Software version 1-15-2015

Takes commands via serial port in this form: <S=_:Z=___:T=___:N=___>

Sprinkler systems supported: Hunter, RainBird

*/

#include <LiquidCrystal.h>

//********************************************************

const int pinSerialOut = 12;

const int pinSerialIn = 13;

const int BuzzerPos = A5;

const int BuzzerNeg = A2;

int varZone = 1;

int varTimeOn = 1;

int varTemp_int;

char varCharRecover_char;

unsigned long varMillisSave_ulong;

byte varTemp_byte = 0;

char varCharSerialRead;

char charMessageSys;

int intMessageZone;

int intMessageTime;

int intMessageNote;

String varString = "";

// Hunter fx Variables

String varP0_String = "11111111010000000000000";

String varP1_String = "00000000000010000000000000";

String varP2_String = "00000000000010000000000000";

String varP3_String = "00000000000010000000000000";

String varP4_String = "001101110000011111110";

// RB fx Variables

const int timetiltrans = 215; //manchester encoding stuff time in uS

const int timeaftertrans = 150; //manchester encoding stuff time in uS

byte arrayOn_Byte[] = {245,245,245,28,4,57,0,1,5,67,B00011100};  //on command zone info in arrayOn_Byte[7]=zone and arrayOn_Byte[9]=zone+66

byte arrayOff_Byte[] = {245,245,245,28,1,64,65,B00011100};  //off command regardles of zone

//--------------------------------------------------------------------------------------------

void setup()

  // Open Serial port

  Serial.begin(9600); 

  Serial.println("<Initialized>");

  // Pin 13 has an LED connected on most Arduino boards:

  //  pinMode(0, INPUT);

  //  pinMode(1, INPUT);

  //  pinMode(2, INPUT);

  pinMode(8, OUTPUT);

  pinMode(9, OUTPUT);

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(7, OUTPUT);

  pinMode(11, INPUT);

  pinMode(12, OUTPUT);

  digitalWrite(12, HIGH);

  pinMode(13, INPUT);

  //digitalWrite(13, HIGH); // Pull up

  pinMode(BuzzerNeg, OUTPUT);

  digitalWrite(BuzzerNeg, LOW);

  pinMode(BuzzerPos, OUTPUT);

  digitalWrite(BuzzerPos, LOW);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(1000);

}

//--------------------------------------------------------------------------------------------

void loop()  { 

  while (Serial.available() > 0) Serial.read(); // Flush the serial receive buffer

  while (Serial.available() == 0)  delay(1);

  if (Serial.available() > 0)  {

    varMillisSave_ulong = millis();

    while ((Serial.available() < 23) && (millis() - varMillisSave_ulong < 250))  delay(1);

    if (Serial.available() < 23)  {

      Serial.println("<Timed Out - Message Short>");

    }

    else  {

      varString = "";

      for (int i=0; i < 23; i++)  {

        varCharSerialRead = Serial.read();

        varString += varCharSerialRead;

      }

      //Parse Message

      if (varString.indexOf('<') != 0)  Serial.println("Message Error - Begin Sentinel");

      else if (varString.indexOf('>') != 22)  Serial.println("Message Error - End Sentinel");

      else if (varString.charAt(1) != 'S')  Serial.println("Message Error - System Parameter");

      else if (varString.charAt(5) != 'Z')  Serial.println("Message Error - Zone Parameter");

      else if (varString.charAt(11) != 'T')  Serial.println("Message Error - Time Parameter");

      else if (varString.charAt(17) != 'N')  Serial.println("Message Error - Note Parameter");

      else  {

        //Passed all parameter checks

        charMessageSys = varString.charAt(3);

        intMessageZone = varString.substring(7,10).toInt();

        intMessageTime = varString.substring(13,16).toInt();

        intMessageNote = varString.substring(19,22).toInt();

        Serial.print("<Valid Message:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(intMessageZone);

        Serial.print(":T=");

        Serial.print(intMessageTime);

        Serial.print(":N=");

        Serial.print(intMessageNote);

        Serial.println(">");

        if (charMessageSys == 'H')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 90)  varTimeOn = 90;

          else varTimeOn = intMessageTime;

          fxPlayHunter();

        }

        if (charMessageSys == 'R')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 1)  varTimeOn = 1;

          else varTimeOn = intMessageTime;

          fxPlayRB();

        }

        Serial.print("<Message Sent:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(varZone);

        Serial.print(":T=");

        Serial.print(varTimeOn);

        Serial.println(">");

      }

    }

  }

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

}

//--------------------------------------------------------------------------------------------

void fxPlayHunter()  {

  //Build message from the front starting with P0

  if (varZone < 13)  {  //Weird change in P0 but it only happens at the zone 12 to 13 transition, phew!

    varP0_String.setCharAt(9,'1');

    varP0_String.setCharAt(10,'0');

  }

  else  {

    varP0_String.setCharAt(9,'0');

    varP0_String.setCharAt(10,'1');

  }

  //P1 here

  varTemp_byte = varZone + 23;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i,'0');

    else  varP1_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 13,'0');

    else  varP1_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 8,'0');

    else  varP1_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 21 - 4,'0');

    else  varP1_String.setCharAt(i + 21 - 4,'1');

  }

  //P2 here

  varTemp_byte = varZone + 35;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i,'0');

    else  varP2_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 13,'0');

    else  varP2_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 8,'0');

    else  varP2_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 21 - 4,'0');

    else  varP2_String.setCharAt(i + 21 - 4,'1');

  }

  //P3 here

  varTemp_byte = varZone + 47;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i,'0');

    else  varP3_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 13,'0');

    else  varP3_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 8,'0');

    else  varP3_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 21 - 4,'0');

    else  varP3_String.setCharAt(i + 21 - 4,'1');

  }

  //P4 here

  varTemp_byte = varZone - 1;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP4_String.setCharAt(i + 8,'0');

    else  varP4_String.setCharAt(i + 8,'1');

  }

  varString = "";

  varString = varP0_String + varP1_String + varP2_String + varP3_String + varP4_String;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  digitalWrite(pinSerialOut, LOW);

  //Serial.print("L");

  delay(320);

  digitalWrite(pinSerialOut, HIGH);

  //Serial.print("H");

  delay(65);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println("L");

  delayMicroseconds(900);

  varTemp_int = varString.length() - 1;

  for (int i=0; i <= varTemp_int; i++)  {

    varCharRecover_char = varString.charAt(i);

    //Serial.write(varCharRecover_char);

    digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(225);

    digitalWrite(pinSerialOut, LOW);

    delayMicroseconds(225);

    if (varCharRecover_char == '0')  digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(1800);

  }

  digitalWrite(pinSerialOut, HIGH);

  //Serial.println("");

  //Serial.println("End");

}

void fxPlayRB()  {

  //Serial.print("Building ON message with zone: ");

  //Serial.println(varZone);

  arrayOn_Byte[7] = varZone;

  arrayOn_Byte[9] = varZone + 66;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  if (varTimeOn == 1)  {  // Send ON message

    for (int ii=0; ii <= 9; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOn_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOn_Byte[10],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  else  {  // Send OFF Message

    for (int ii=0; ii <= 6; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOff_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOff_Byte[7],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  delayMicroseconds(timeaftertrans);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println();

  //Serial.println("End");

}

  Are you sure? yes | no

chadclick wrote 14 hours ago point

Please cut and paste the source code below into the arduino app.

  Are you sure? yes | no

chadclick wrote 14 hours ago point

/*

WK Arduino Software version 1-15-2015

Takes commands via serial port in this form: <S=_:Z=___:T=___:N=___>

Sprinkler systems supported: Hunter, RainBird

*/

#include <LiquidCrystal.h>

//********************************************************

const int pinSerialOut = 12;

const int pinSerialIn = 13;

const int BuzzerPos = A5;

const int BuzzerNeg = A2;

int varZone = 1;

int varTimeOn = 1;

int varTemp_int;

char varCharRecover_char;

unsigned long varMillisSave_ulong;

byte varTemp_byte = 0;

char varCharSerialRead;

char charMessageSys;

int intMessageZone;

int intMessageTime;

int intMessageNote;

String varString = "";

// Hunter fx Variables

String varP0_String = "11111111010000000000000";

String varP1_String = "00000000000010000000000000";

String varP2_String = "00000000000010000000000000";

String varP3_String = "00000000000010000000000000";

String varP4_String = "001101110000011111110";

// RB fx Variables

const int timetiltrans = 215; //manchester encoding stuff time in uS

const int timeaftertrans = 150; //manchester encoding stuff time in uS

byte arrayOn_Byte[] = {245,245,245,28,4,57,0,1,5,67,B00011100};  //on command zone info in arrayOn_Byte[7]=zone and arrayOn_Byte[9]=zone+66

byte arrayOff_Byte[] = {245,245,245,28,1,64,65,B00011100};  //off command regardles of zone

//--------------------------------------------------------------------------------------------

void setup()

  // Open Serial port

  Serial.begin(9600); 

  Serial.println("<Initialized>");

  // Pin 13 has an LED connected on most Arduino boards:

  //  pinMode(0, INPUT);

  //  pinMode(1, INPUT);

  //  pinMode(2, INPUT);

  pinMode(8, OUTPUT);

  pinMode(9, OUTPUT);

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(7, OUTPUT);

  pinMode(11, INPUT);

  pinMode(12, OUTPUT);

  digitalWrite(12, HIGH);

  pinMode(13, INPUT);

  //digitalWrite(13, HIGH); // Pull up

  pinMode(BuzzerNeg, OUTPUT);

  digitalWrite(BuzzerNeg, LOW);

  pinMode(BuzzerPos, OUTPUT);

  digitalWrite(BuzzerPos, LOW);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(1000);

}

//--------------------------------------------------------------------------------------------

void loop()  { 

  while (Serial.available() > 0) Serial.read(); // Flush the serial receive buffer

  while (Serial.available() == 0)  delay(1);

  if (Serial.available() > 0)  {

    varMillisSave_ulong = millis();

    while ((Serial.available() < 23) && (millis() - varMillisSave_ulong < 250))  delay(1);

    if (Serial.available() < 23)  {

      Serial.println("<Timed Out - Message Short>");

    }

    else  {

      varString = "";

      for (int i=0; i < 23; i++)  {

        varCharSerialRead = Serial.read();

        varString += varCharSerialRead;

      }

      //Parse Message

      if (varString.indexOf('<') != 0)  Serial.println("Message Error - Begin Sentinel");

      else if (varString.indexOf('>') != 22)  Serial.println("Message Error - End Sentinel");

      else if (varString.charAt(1) != 'S')  Serial.println("Message Error - System Parameter");

      else if (varString.charAt(5) != 'Z')  Serial.println("Message Error - Zone Parameter");

      else if (varString.charAt(11) != 'T')  Serial.println("Message Error - Time Parameter");

      else if (varString.charAt(17) != 'N')  Serial.println("Message Error - Note Parameter");

      else  {

        //Passed all parameter checks

        charMessageSys = varString.charAt(3);

        intMessageZone = varString.substring(7,10).toInt();

        intMessageTime = varString.substring(13,16).toInt();

        intMessageNote = varString.substring(19,22).toInt();

        Serial.print("<Valid Message:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(intMessageZone);

        Serial.print(":T=");

        Serial.print(intMessageTime);

        Serial.print(":N=");

        Serial.print(intMessageNote);

        Serial.println(">");

        if (charMessageSys == 'H')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 90)  varTimeOn = 90;

          else varTimeOn = intMessageTime;

          fxPlayHunter();

        }

        if (charMessageSys == 'R')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 1)  varTimeOn = 1;

          else varTimeOn = intMessageTime;

          fxPlayRB();

        }

        Serial.print("<Message Sent:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(varZone);

        Serial.print(":T=");

        Serial.print(varTimeOn);

        Serial.println(">");

      }

    }

  }

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

}

//--------------------------------------------------------------------------------------------

void fxPlayHunter()  {

  //Build message from the front starting with P0

  if (varZone < 13)  {  //Weird change in P0 but it only happens at the zone 12 to 13 transition, phew!

    varP0_String.setCharAt(9,'1');

    varP0_String.setCharAt(10,'0');

  }

  else  {

    varP0_String.setCharAt(9,'0');

    varP0_String.setCharAt(10,'1');

  }

  //P1 here

  varTemp_byte = varZone + 23;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i,'0');

    else  varP1_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 13,'0');

    else  varP1_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 8,'0');

    else  varP1_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 21 - 4,'0');

    else  varP1_String.setCharAt(i + 21 - 4,'1');

  }

  //P2 here

  varTemp_byte = varZone + 35;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i,'0');

    else  varP2_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 13,'0');

    else  varP2_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 8,'0');

    else  varP2_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 21 - 4,'0');

    else  varP2_String.setCharAt(i + 21 - 4,'1');

  }

  //P3 here

  varTemp_byte = varZone + 47;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i,'0');

    else  varP3_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 13,'0');

    else  varP3_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 8,'0');

    else  varP3_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 21 - 4,'0');

    else  varP3_String.setCharAt(i + 21 - 4,'1');

  }

  //P4 here

  varTemp_byte = varZone - 1;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP4_String.setCharAt(i + 8,'0');

    else  varP4_String.setCharAt(i + 8,'1');

  }

  varString = "";

  varString = varP0_String + varP1_String + varP2_String + varP3_String + varP4_String;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  digitalWrite(pinSerialOut, LOW);

  //Serial.print("L");

  delay(320);

  digitalWrite(pinSerialOut, HIGH);

  //Serial.print("H");

  delay(65);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println("L");

  delayMicroseconds(900);

  varTemp_int = varString.length() - 1;

  for (int i=0; i <= varTemp_int; i++)  {

    varCharRecover_char = varString.charAt(i);

    //Serial.write(varCharRecover_char);

    digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(225);

    digitalWrite(pinSerialOut, LOW);

    delayMicroseconds(225);

    if (varCharRecover_char == '0')  digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(1800);

  }

  digitalWrite(pinSerialOut, HIGH);

  //Serial.println("");

  //Serial.println("End");

}

void fxPlayRB()  {

  //Serial.print("Building ON message with zone: ");

  //Serial.println(varZone);

  arrayOn_Byte[7] = varZone;

  arrayOn_Byte[9] = varZone + 66;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  if (varTimeOn == 1)  {  // Send ON message

    for (int ii=0; ii <= 9; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOn_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOn_Byte[10],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  else  {  // Send OFF Message

    for (int ii=0; ii <= 6; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOff_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOff_Byte[7],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  delayMicroseconds(timeaftertrans);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println();

  //Serial.println("End");

}

  Are you sure? yes | no

Andrew wrote 10/06/2017 at 22:21 point

Hi there.  Your board has been out of stock on Tindie for two years now.  Have you considered releasing your code, schematics, and PCB artwork under an Open license?  I have a Hunter X-Core I want to control remotely with an ESP8266.  I can rewrite some Arduino code I found elsewhere, but I would rather not have to.  Thanks.

  Are you sure? yes | no

John Matthias Syrinek wrote 04/22/2020 at 03:37 point

Same question - thank you!

  Are you sure? yes | no

Andrew wrote 04/22/2020 at 03:44 point

I wouldn't hold your breath. I got fed up with the awful user interface on the Hunter controller and replaced it with an ESP8266 running ESPeasy and controlled by Domoticz. So. Much. Better.

  Are you sure? yes | no

chadclick wrote 14 hours ago point

/*

WK Arduino Software version 1-15-2015

By: WATERKARMA

Takes commands via serial port in this form: <S=_:Z=___:T=___:N=___>

Sprinkler systems supported: Hunter, RainBird

*/

#include <LiquidCrystal.h>

//********************************************************

const int pinSerialOut = 12;

const int pinSerialIn = 13;

const int BuzzerPos = A5;

const int BuzzerNeg = A2;

int varZone = 1;

int varTimeOn = 1;

int varTemp_int;

char varCharRecover_char;

unsigned long varMillisSave_ulong;

byte varTemp_byte = 0;

char varCharSerialRead;

char charMessageSys;

int intMessageZone;

int intMessageTime;

int intMessageNote;

String varString = "";

// Hunter fx Variables

String varP0_String = "11111111010000000000000";

String varP1_String = "00000000000010000000000000";

String varP2_String = "00000000000010000000000000";

String varP3_String = "00000000000010000000000000";

String varP4_String = "001101110000011111110";

// RB fx Variables

const int timetiltrans = 215; //manchester encoding stuff time in uS

const int timeaftertrans = 150; //manchester encoding stuff time in uS

byte arrayOn_Byte[] = {245,245,245,28,4,57,0,1,5,67,B00011100};  //on command zone info in arrayOn_Byte[7]=zone and arrayOn_Byte[9]=zone+66

byte arrayOff_Byte[] = {245,245,245,28,1,64,65,B00011100};  //off command regardles of zone

//--------------------------------------------------------------------------------------------

void setup()

  // Open Serial port

  Serial.begin(9600); 

  Serial.println("<Initialized>");

  // Pin 13 has an LED connected on most Arduino boards:

  //  pinMode(0, INPUT);

  //  pinMode(1, INPUT);

  //  pinMode(2, INPUT);

  pinMode(8, OUTPUT);

  pinMode(9, OUTPUT);

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(7, OUTPUT);

  pinMode(11, INPUT);

  pinMode(12, OUTPUT);

  digitalWrite(12, HIGH);

  pinMode(13, INPUT);

  //digitalWrite(13, HIGH); // Pull up

  pinMode(BuzzerNeg, OUTPUT);

  digitalWrite(BuzzerNeg, LOW);

  pinMode(BuzzerPos, OUTPUT);

  digitalWrite(BuzzerPos, LOW);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(1000);

}

//--------------------------------------------------------------------------------------------

void loop()  { 

  while (Serial.available() > 0) Serial.read(); // Flush the serial receive buffer

  while (Serial.available() == 0)  delay(1);

  if (Serial.available() > 0)  {

    varMillisSave_ulong = millis();

    while ((Serial.available() < 23) && (millis() - varMillisSave_ulong < 250))  delay(1);

    if (Serial.available() < 23)  {

      Serial.println("<Timed Out - Message Short>");

    }

    else  {

      varString = "";

      for (int i=0; i < 23; i++)  {

        varCharSerialRead = Serial.read();

        varString += varCharSerialRead;

      }

      //Parse Message

      if (varString.indexOf('<') != 0)  Serial.println("Message Error - Begin Sentinel");

      else if (varString.indexOf('>') != 22)  Serial.println("Message Error - End Sentinel");

      else if (varString.charAt(1) != 'S')  Serial.println("Message Error - System Parameter");

      else if (varString.charAt(5) != 'Z')  Serial.println("Message Error - Zone Parameter");

      else if (varString.charAt(11) != 'T')  Serial.println("Message Error - Time Parameter");

      else if (varString.charAt(17) != 'N')  Serial.println("Message Error - Note Parameter");

      else  {

        //Passed all parameter checks

        charMessageSys = varString.charAt(3);

        intMessageZone = varString.substring(7,10).toInt();

        intMessageTime = varString.substring(13,16).toInt();

        intMessageNote = varString.substring(19,22).toInt();

        Serial.print("<Valid Message:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(intMessageZone);

        Serial.print(":T=");

        Serial.print(intMessageTime);

        Serial.print(":N=");

        Serial.print(intMessageNote);

        Serial.println(">");

        if (charMessageSys == 'H')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 90)  varTimeOn = 90;

          else varTimeOn = intMessageTime;

          fxPlayHunter();

        }

        if (charMessageSys == 'R')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 1)  varTimeOn = 1;

          else varTimeOn = intMessageTime;

          fxPlayRB();

        }

        Serial.print("<Message Sent:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(varZone);

        Serial.print(":T=");

        Serial.print(varTimeOn);

        Serial.println(">");

      }

    }

  }

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

}

//--------------------------------------------------------------------------------------------

void fxPlayHunter()  {

  //Build message from the front starting with P0

  if (varZone < 13)  {  //Weird change in P0 but it only happens at the zone 12 to 13 transition, phew!

    varP0_String.setCharAt(9,'1');

    varP0_String.setCharAt(10,'0');

  }

  else  {

    varP0_String.setCharAt(9,'0');

    varP0_String.setCharAt(10,'1');

  }

  //P1 here

  varTemp_byte = varZone + 23;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i,'0');

    else  varP1_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 13,'0');

    else  varP1_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 8,'0');

    else  varP1_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 21 - 4,'0');

    else  varP1_String.setCharAt(i + 21 - 4,'1');

  }

  //P2 here

  varTemp_byte = varZone + 35;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i,'0');

    else  varP2_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 13,'0');

    else  varP2_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 8,'0');

    else  varP2_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 21 - 4,'0');

    else  varP2_String.setCharAt(i + 21 - 4,'1');

  }

  //P3 here

  varTemp_byte = varZone + 47;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i,'0');

    else  varP3_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 13,'0');

    else  varP3_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 8,'0');

    else  varP3_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 21 - 4,'0');

    else  varP3_String.setCharAt(i + 21 - 4,'1');

  }

  //P4 here

  varTemp_byte = varZone - 1;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP4_String.setCharAt(i + 8,'0');

    else  varP4_String.setCharAt(i + 8,'1');

  }

  varString = "";

  varString = varP0_String + varP1_String + varP2_String + varP3_String + varP4_String;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  digitalWrite(pinSerialOut, LOW);

  //Serial.print("L");

  delay(320);

  digitalWrite(pinSerialOut, HIGH);

  //Serial.print("H");

  delay(65);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println("L");

  delayMicroseconds(900);

  varTemp_int = varString.length() - 1;

  for (int i=0; i <= varTemp_int; i++)  {

    varCharRecover_char = varString.charAt(i);

    //Serial.write(varCharRecover_char);

    digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(225);

    digitalWrite(pinSerialOut, LOW);

    delayMicroseconds(225);

    if (varCharRecover_char == '0')  digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(1800);

  }

  digitalWrite(pinSerialOut, HIGH);

  //Serial.println("");

  //Serial.println("End");

}

void fxPlayRB()  {

  //Serial.print("Building ON message with zone: ");

  //Serial.println(varZone);

  arrayOn_Byte[7] = varZone;

  arrayOn_Byte[9] = varZone + 66;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  if (varTimeOn == 1)  {  // Send ON message

    for (int ii=0; ii <= 9; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOn_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOn_Byte[10],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  else  {  // Send OFF Message

    for (int ii=0; ii <= 6; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOff_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOff_Byte[7],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  delayMicroseconds(timeaftertrans);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println();

  //Serial.println("End");

}

  Are you sure? yes | no

chadclick wrote 14 hours ago point

/*

WK Arduino Software version 1-15-2015

By: WATERKARMA

Takes commands via serial port in this form: <S=_:Z=___:T=___:N=___>

Sprinkler systems supported: Hunter, RainBird

*/

#include <LiquidCrystal.h>

//********************************************************

const int pinSerialOut = 12;

const int pinSerialIn = 13;

const int BuzzerPos = A5;

const int BuzzerNeg = A2;

int varZone = 1;

int varTimeOn = 1;

int varTemp_int;

char varCharRecover_char;

unsigned long varMillisSave_ulong;

byte varTemp_byte = 0;

char varCharSerialRead;

char charMessageSys;

int intMessageZone;

int intMessageTime;

int intMessageNote;

String varString = "";

// Hunter fx Variables

String varP0_String = "11111111010000000000000";

String varP1_String = "00000000000010000000000000";

String varP2_String = "00000000000010000000000000";

String varP3_String = "00000000000010000000000000";

String varP4_String = "001101110000011111110";

// RB fx Variables

const int timetiltrans = 215; //manchester encoding stuff time in uS

const int timeaftertrans = 150; //manchester encoding stuff time in uS

byte arrayOn_Byte[] = {245,245,245,28,4,57,0,1,5,67,B00011100};  //on command zone info in arrayOn_Byte[7]=zone and arrayOn_Byte[9]=zone+66

byte arrayOff_Byte[] = {245,245,245,28,1,64,65,B00011100};  //off command regardles of zone

//--------------------------------------------------------------------------------------------

void setup()

  // Open Serial port

  Serial.begin(9600); 

  Serial.println("<Initialized>");

  // Pin 13 has an LED connected on most Arduino boards:

  //  pinMode(0, INPUT);

  //  pinMode(1, INPUT);

  //  pinMode(2, INPUT);

  pinMode(8, OUTPUT);

  pinMode(9, OUTPUT);

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(7, OUTPUT);

  pinMode(11, INPUT);

  pinMode(12, OUTPUT);

  digitalWrite(12, HIGH);

  pinMode(13, INPUT);

  //digitalWrite(13, HIGH); // Pull up

  pinMode(BuzzerNeg, OUTPUT);

  digitalWrite(BuzzerNeg, LOW);

  pinMode(BuzzerPos, OUTPUT);

  digitalWrite(BuzzerPos, LOW);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(1000);

}

//--------------------------------------------------------------------------------------------

void loop()  { 

  while (Serial.available() > 0) Serial.read(); // Flush the serial receive buffer

  while (Serial.available() == 0)  delay(1);

  if (Serial.available() > 0)  {

    varMillisSave_ulong = millis();

    while ((Serial.available() < 23) && (millis() - varMillisSave_ulong < 250))  delay(1);

    if (Serial.available() < 23)  {

      Serial.println("<Timed Out - Message Short>");

    }

    else  {

      varString = "";

      for (int i=0; i < 23; i++)  {

        varCharSerialRead = Serial.read();

        varString += varCharSerialRead;

      }

      //Parse Message

      if (varString.indexOf('<') != 0)  Serial.println("Message Error - Begin Sentinel");

      else if (varString.indexOf('>') != 22)  Serial.println("Message Error - End Sentinel");

      else if (varString.charAt(1) != 'S')  Serial.println("Message Error - System Parameter");

      else if (varString.charAt(5) != 'Z')  Serial.println("Message Error - Zone Parameter");

      else if (varString.charAt(11) != 'T')  Serial.println("Message Error - Time Parameter");

      else if (varString.charAt(17) != 'N')  Serial.println("Message Error - Note Parameter");

      else  {

        //Passed all parameter checks

        charMessageSys = varString.charAt(3);

        intMessageZone = varString.substring(7,10).toInt();

        intMessageTime = varString.substring(13,16).toInt();

        intMessageNote = varString.substring(19,22).toInt();

        Serial.print("<Valid Message:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(intMessageZone);

        Serial.print(":T=");

        Serial.print(intMessageTime);

        Serial.print(":N=");

        Serial.print(intMessageNote);

        Serial.println(">");

        if (charMessageSys == 'H')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 90)  varTimeOn = 90;

          else varTimeOn = intMessageTime;

          fxPlayHunter();

        }

        if (charMessageSys == 'R')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 1)  varTimeOn = 1;

          else varTimeOn = intMessageTime;

          fxPlayRB();

        }

        Serial.print("<Message Sent:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(varZone);

        Serial.print(":T=");

        Serial.print(varTimeOn);

        Serial.println(">");

      }

    }

  }

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

}

//--------------------------------------------------------------------------------------------

void fxPlayHunter()  {

  //Build message from the front starting with P0

  if (varZone < 13)  {  //Weird change in P0 but it only happens at the zone 12 to 13 transition, phew!

    varP0_String.setCharAt(9,'1');

    varP0_String.setCharAt(10,'0');

  }

  else  {

    varP0_String.setCharAt(9,'0');

    varP0_String.setCharAt(10,'1');

  }

  //P1 here

  varTemp_byte = varZone + 23;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i,'0');

    else  varP1_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 13,'0');

    else  varP1_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 8,'0');

    else  varP1_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 21 - 4,'0');

    else  varP1_String.setCharAt(i + 21 - 4,'1');

  }

  //P2 here

  varTemp_byte = varZone + 35;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i,'0');

    else  varP2_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 13,'0');

    else  varP2_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 8,'0');

    else  varP2_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 21 - 4,'0');

    else  varP2_String.setCharAt(i + 21 - 4,'1');

  }

  //P3 here

  varTemp_byte = varZone + 47;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i,'0');

    else  varP3_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 13,'0');

    else  varP3_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 8,'0');

    else  varP3_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 21 - 4,'0');

    else  varP3_String.setCharAt(i + 21 - 4,'1');

  }

  //P4 here

  varTemp_byte = varZone - 1;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP4_String.setCharAt(i + 8,'0');

    else  varP4_String.setCharAt(i + 8,'1');

  }

  varString = "";

  varString = varP0_String + varP1_String + varP2_String + varP3_String + varP4_String;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  digitalWrite(pinSerialOut, LOW);

  //Serial.print("L");

  delay(320);

  digitalWrite(pinSerialOut, HIGH);

  //Serial.print("H");

  delay(65);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println("L");

  delayMicroseconds(900);

  varTemp_int = varString.length() - 1;

  for (int i=0; i <= varTemp_int; i++)  {

    varCharRecover_char = varString.charAt(i);

    //Serial.write(varCharRecover_char);

    digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(225);

    digitalWrite(pinSerialOut, LOW);

    delayMicroseconds(225);

    if (varCharRecover_char == '0')  digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(1800);

  }

  digitalWrite(pinSerialOut, HIGH);

  //Serial.println("");

  //Serial.println("End");

}

void fxPlayRB()  {

  //Serial.print("Building ON message with zone: ");

  //Serial.println(varZone);

  arrayOn_Byte[7] = varZone;

  arrayOn_Byte[9] = varZone + 66;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  if (varTimeOn == 1)  {  // Send ON message

    for (int ii=0; ii <= 9; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOn_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOn_Byte[10],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  else  {  // Send OFF Message

    for (int ii=0; ii <= 6; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOff_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOff_Byte[7],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  delayMicroseconds(timeaftertrans);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println();

  //Serial.println("End");

}

  Are you sure? yes | no

chadclick wrote 14 hours ago point

Uploaded source code today.

  Are you sure? yes | no

Jim wrote 11/01/2016 at 20:06 point

Hi, I have 2 12-Station SST1200o on my property.  Can we make the Waterkarma board work with these controllers?  If so, I will need details.  

  Are you sure? yes | no

Ramanan wrote 08/11/2016 at 17:14 point

Hi, we have a Rainbird ESP-ME system. Can you send me the details of how to connect the Waterkarma board to it. After reviewing, I would like to purchase such a board.

  Are you sure? yes | no

chadclick wrote 14 hours ago point

/*

WK Arduino Software version 1-15-2015

By: WATERKARMA

Takes commands via serial port in this form: <S=_:Z=___:T=___:N=___>

Sprinkler systems supported: Hunter, RainBird

*/

#include <LiquidCrystal.h>

//********************************************************

const int pinSerialOut = 12;

const int pinSerialIn = 13;

const int BuzzerPos = A5;

const int BuzzerNeg = A2;

int varZone = 1;

int varTimeOn = 1;

int varTemp_int;

char varCharRecover_char;

unsigned long varMillisSave_ulong;

byte varTemp_byte = 0;

char varCharSerialRead;

char charMessageSys;

int intMessageZone;

int intMessageTime;

int intMessageNote;

String varString = "";

// Hunter fx Variables

String varP0_String = "11111111010000000000000";

String varP1_String = "00000000000010000000000000";

String varP2_String = "00000000000010000000000000";

String varP3_String = "00000000000010000000000000";

String varP4_String = "001101110000011111110";

// RB fx Variables

const int timetiltrans = 215; //manchester encoding stuff time in uS

const int timeaftertrans = 150; //manchester encoding stuff time in uS

byte arrayOn_Byte[] = {245,245,245,28,4,57,0,1,5,67,B00011100};  //on command zone info in arrayOn_Byte[7]=zone and arrayOn_Byte[9]=zone+66

byte arrayOff_Byte[] = {245,245,245,28,1,64,65,B00011100};  //off command regardles of zone

//--------------------------------------------------------------------------------------------

void setup()

  // Open Serial port

  Serial.begin(9600); 

  Serial.println("<Initialized>");

  // Pin 13 has an LED connected on most Arduino boards:

  //  pinMode(0, INPUT);

  //  pinMode(1, INPUT);

  //  pinMode(2, INPUT);

  pinMode(8, OUTPUT);

  pinMode(9, OUTPUT);

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(7, OUTPUT);

  pinMode(11, INPUT);

  pinMode(12, OUTPUT);

  digitalWrite(12, HIGH);

  pinMode(13, INPUT);

  //digitalWrite(13, HIGH); // Pull up

  pinMode(BuzzerNeg, OUTPUT);

  digitalWrite(BuzzerNeg, LOW);

  pinMode(BuzzerPos, OUTPUT);

  digitalWrite(BuzzerPos, LOW);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(1000);

}

//--------------------------------------------------------------------------------------------

void loop()  { 

  while (Serial.available() > 0) Serial.read(); // Flush the serial receive buffer

  while (Serial.available() == 0)  delay(1);

  if (Serial.available() > 0)  {

    varMillisSave_ulong = millis();

    while ((Serial.available() < 23) && (millis() - varMillisSave_ulong < 250))  delay(1);

    if (Serial.available() < 23)  {

      Serial.println("<Timed Out - Message Short>");

    }

    else  {

      varString = "";

      for (int i=0; i < 23; i++)  {

        varCharSerialRead = Serial.read();

        varString += varCharSerialRead;

      }

      //Parse Message

      if (varString.indexOf('<') != 0)  Serial.println("Message Error - Begin Sentinel");

      else if (varString.indexOf('>') != 22)  Serial.println("Message Error - End Sentinel");

      else if (varString.charAt(1) != 'S')  Serial.println("Message Error - System Parameter");

      else if (varString.charAt(5) != 'Z')  Serial.println("Message Error - Zone Parameter");

      else if (varString.charAt(11) != 'T')  Serial.println("Message Error - Time Parameter");

      else if (varString.charAt(17) != 'N')  Serial.println("Message Error - Note Parameter");

      else  {

        //Passed all parameter checks

        charMessageSys = varString.charAt(3);

        intMessageZone = varString.substring(7,10).toInt();

        intMessageTime = varString.substring(13,16).toInt();

        intMessageNote = varString.substring(19,22).toInt();

        Serial.print("<Valid Message:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(intMessageZone);

        Serial.print(":T=");

        Serial.print(intMessageTime);

        Serial.print(":N=");

        Serial.print(intMessageNote);

        Serial.println(">");

        if (charMessageSys == 'H')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 90)  varTimeOn = 90;

          else varTimeOn = intMessageTime;

          fxPlayHunter();

        }

        if (charMessageSys == 'R')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 1)  varTimeOn = 1;

          else varTimeOn = intMessageTime;

          fxPlayRB();

        }

        Serial.print("<Message Sent:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(varZone);

        Serial.print(":T=");

        Serial.print(varTimeOn);

        Serial.println(">");

      }

    }

  }

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

}

//--------------------------------------------------------------------------------------------

void fxPlayHunter()  {

  //Build message from the front starting with P0

  if (varZone < 13)  {  //Weird change in P0 but it only happens at the zone 12 to 13 transition, phew!

    varP0_String.setCharAt(9,'1');

    varP0_String.setCharAt(10,'0');

  }

  else  {

    varP0_String.setCharAt(9,'0');

    varP0_String.setCharAt(10,'1');

  }

  //P1 here

  varTemp_byte = varZone + 23;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i,'0');

    else  varP1_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 13,'0');

    else  varP1_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 8,'0');

    else  varP1_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 21 - 4,'0');

    else  varP1_String.setCharAt(i + 21 - 4,'1');

  }

  //P2 here

  varTemp_byte = varZone + 35;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i,'0');

    else  varP2_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 13,'0');

    else  varP2_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 8,'0');

    else  varP2_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 21 - 4,'0');

    else  varP2_String.setCharAt(i + 21 - 4,'1');

  }

  //P3 here

  varTemp_byte = varZone + 47;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i,'0');

    else  varP3_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 13,'0');

    else  varP3_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 8,'0');

    else  varP3_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 21 - 4,'0');

    else  varP3_String.setCharAt(i + 21 - 4,'1');

  }

  //P4 here

  varTemp_byte = varZone - 1;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP4_String.setCharAt(i + 8,'0');

    else  varP4_String.setCharAt(i + 8,'1');

  }

  varString = "";

  varString = varP0_String + varP1_String + varP2_String + varP3_String + varP4_String;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  digitalWrite(pinSerialOut, LOW);

  //Serial.print("L");

  delay(320);

  digitalWrite(pinSerialOut, HIGH);

  //Serial.print("H");

  delay(65);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println("L");

  delayMicroseconds(900);

  varTemp_int = varString.length() - 1;

  for (int i=0; i <= varTemp_int; i++)  {

    varCharRecover_char = varString.charAt(i);

    //Serial.write(varCharRecover_char);

    digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(225);

    digitalWrite(pinSerialOut, LOW);

    delayMicroseconds(225);

    if (varCharRecover_char == '0')  digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(1800);

  }

  digitalWrite(pinSerialOut, HIGH);

  //Serial.println("");

  //Serial.println("End");

}

void fxPlayRB()  {

  //Serial.print("Building ON message with zone: ");

  //Serial.println(varZone);

  arrayOn_Byte[7] = varZone;

  arrayOn_Byte[9] = varZone + 66;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  if (varTimeOn == 1)  {  // Send ON message

    for (int ii=0; ii <= 9; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOn_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOn_Byte[10],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  else  {  // Send OFF Message

    for (int ii=0; ii <= 6; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOff_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOff_Byte[7],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  delayMicroseconds(timeaftertrans);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println();

  //Serial.println("End");

}

  Are you sure? yes | no

chadclick wrote 09/07/2015 at 06:07 point

I sell on Tindie

  Are you sure? yes | no

chadclick wrote 08/27/2015 at 01:32 point

Oh, forgot to mention we did a full tear down on the Rachio and while it's name implies Input/Output, ".io" it's not.  It's one way comm only.  No sensor data, nada.  It's about 1/4 the quality of a Hunter Pro-C or Rain Bird Esp.  The Rachio pcb and hardware config is lacking.

  Are you sure? yes | no

chadclick wrote 08/27/2015 at 01:28 point

You have a 36 zone irrigation system at your estate.  Last year you purchased a Hunter ACC encoder/decoder system ($2000).   All your friends are controlling their systems via iPhone and since you vacation 6 months out the year you'd like to do that too.  Right now you have pretty much one option.  Buy 3 Rachio 12 zone units, get 3 phones and 3 apple Id's .  The Rachios will set you back  $900 alone.  Then take your $2000 Hunter ACC off the wall and throw it in the trash can.  Make sure to have your irrigation contractor do the entire install/rebuild ($1000+).  It doesn't make sense.  I have the Plug and Play Cloud Based conversion module that is the solution.                                                    

  Are you sure? yes | no

Hentry Sombers wrote 08/27/2015 at 00:59 point

Interesting concept.  So this would work like an rach.io or the others.?  I guess this keeps the electrical hardware in place and adds a smart control for limiting and controlling watering based on rain/weather etc

  Are you sure? yes | no

chadclick wrote 14 hours ago point

/*

WK Arduino Software version 1-15-2015

By: WATERKARMA

Takes commands via serial port in this form: <S=_:Z=___:T=___:N=___>

Sprinkler systems supported: Hunter, RainBird

*/

#include <LiquidCrystal.h>

//********************************************************

const int pinSerialOut = 12;

const int pinSerialIn = 13;

const int BuzzerPos = A5;

const int BuzzerNeg = A2;

int varZone = 1;

int varTimeOn = 1;

int varTemp_int;

char varCharRecover_char;

unsigned long varMillisSave_ulong;

byte varTemp_byte = 0;

char varCharSerialRead;

char charMessageSys;

int intMessageZone;

int intMessageTime;

int intMessageNote;

String varString = "";

// Hunter fx Variables

String varP0_String = "11111111010000000000000";

String varP1_String = "00000000000010000000000000";

String varP2_String = "00000000000010000000000000";

String varP3_String = "00000000000010000000000000";

String varP4_String = "001101110000011111110";

// RB fx Variables

const int timetiltrans = 215; //manchester encoding stuff time in uS

const int timeaftertrans = 150; //manchester encoding stuff time in uS

byte arrayOn_Byte[] = {245,245,245,28,4,57,0,1,5,67,B00011100};  //on command zone info in arrayOn_Byte[7]=zone and arrayOn_Byte[9]=zone+66

byte arrayOff_Byte[] = {245,245,245,28,1,64,65,B00011100};  //off command regardles of zone

//--------------------------------------------------------------------------------------------

void setup()

  // Open Serial port

  Serial.begin(9600); 

  Serial.println("<Initialized>");

  // Pin 13 has an LED connected on most Arduino boards:

  //  pinMode(0, INPUT);

  //  pinMode(1, INPUT);

  //  pinMode(2, INPUT);

  pinMode(8, OUTPUT);

  pinMode(9, OUTPUT);

  pinMode(4, OUTPUT);

  pinMode(5, OUTPUT);

  pinMode(6, OUTPUT);

  pinMode(7, OUTPUT);

  pinMode(11, INPUT);

  pinMode(12, OUTPUT);

  digitalWrite(12, HIGH);

  pinMode(13, INPUT);

  //digitalWrite(13, HIGH); // Pull up

  pinMode(BuzzerNeg, OUTPUT);

  digitalWrite(BuzzerNeg, LOW);

  pinMode(BuzzerPos, OUTPUT);

  digitalWrite(BuzzerPos, LOW);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(200);

  digitalWrite(BuzzerPos, 1);

  delay(100);

  digitalWrite(BuzzerPos, 0);

  delay(1000);

}

//--------------------------------------------------------------------------------------------

void loop()  { 

  while (Serial.available() > 0) Serial.read(); // Flush the serial receive buffer

  while (Serial.available() == 0)  delay(1);

  if (Serial.available() > 0)  {

    varMillisSave_ulong = millis();

    while ((Serial.available() < 23) && (millis() - varMillisSave_ulong < 250))  delay(1);

    if (Serial.available() < 23)  {

      Serial.println("<Timed Out - Message Short>");

    }

    else  {

      varString = "";

      for (int i=0; i < 23; i++)  {

        varCharSerialRead = Serial.read();

        varString += varCharSerialRead;

      }

      //Parse Message

      if (varString.indexOf('<') != 0)  Serial.println("Message Error - Begin Sentinel");

      else if (varString.indexOf('>') != 22)  Serial.println("Message Error - End Sentinel");

      else if (varString.charAt(1) != 'S')  Serial.println("Message Error - System Parameter");

      else if (varString.charAt(5) != 'Z')  Serial.println("Message Error - Zone Parameter");

      else if (varString.charAt(11) != 'T')  Serial.println("Message Error - Time Parameter");

      else if (varString.charAt(17) != 'N')  Serial.println("Message Error - Note Parameter");

      else  {

        //Passed all parameter checks

        charMessageSys = varString.charAt(3);

        intMessageZone = varString.substring(7,10).toInt();

        intMessageTime = varString.substring(13,16).toInt();

        intMessageNote = varString.substring(19,22).toInt();

        Serial.print("<Valid Message:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(intMessageZone);

        Serial.print(":T=");

        Serial.print(intMessageTime);

        Serial.print(":N=");

        Serial.print(intMessageNote);

        Serial.println(">");

        if (charMessageSys == 'H')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 90)  varTimeOn = 90;

          else varTimeOn = intMessageTime;

          fxPlayHunter();

        }

        if (charMessageSys == 'R')  {

          if (intMessageZone < 1)  varZone = 1;

          else if (intMessageZone > 48)  varZone = 48;

          else varZone = intMessageZone;

          if (intMessageTime < 0)  varTimeOn = 0;

          else if (intMessageTime > 1)  varTimeOn = 1;

          else varTimeOn = intMessageTime;

          fxPlayRB();

        }

        Serial.print("<Message Sent:S=");

        Serial.print(charMessageSys);

        Serial.print(":Z=");

        Serial.print(varZone);

        Serial.print(":T=");

        Serial.print(varTimeOn);

        Serial.println(">");

      }

    }

  }

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

}

//--------------------------------------------------------------------------------------------

void fxPlayHunter()  {

  //Build message from the front starting with P0

  if (varZone < 13)  {  //Weird change in P0 but it only happens at the zone 12 to 13 transition, phew!

    varP0_String.setCharAt(9,'1');

    varP0_String.setCharAt(10,'0');

  }

  else  {

    varP0_String.setCharAt(9,'0');

    varP0_String.setCharAt(10,'1');

  }

  //P1 here

  varTemp_byte = varZone + 23;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i,'0');

    else  varP1_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 13,'0');

    else  varP1_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 8,'0');

    else  varP1_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP1_String.setCharAt(i + 21 - 4,'0');

    else  varP1_String.setCharAt(i + 21 - 4,'1');

  }

  //P2 here

  varTemp_byte = varZone + 35;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i,'0');

    else  varP2_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 13,'0');

    else  varP2_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 8,'0');

    else  varP2_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP2_String.setCharAt(i + 21 - 4,'0');

    else  varP2_String.setCharAt(i + 21 - 4,'1');

  }

  //P3 here

  varTemp_byte = varZone + 47;

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i,'0');

    else  varP3_String.setCharAt(i,'1');

  }

  for (int i=0; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 13,'0');

    else  varP3_String.setCharAt(i + 13,'1');

  }

  varTemp_byte = varTimeOn;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 8,'0');

    else  varP3_String.setCharAt(i + 8,'1');

  }

  for (int i=4; i <= 6; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP3_String.setCharAt(i + 21 - 4,'0');

    else  varP3_String.setCharAt(i + 21 - 4,'1');

  }

  //P4 here

  varTemp_byte = varZone - 1;

  for (int i=0; i <= 3; i++)  {

    if (bitRead(varTemp_byte,i) == 0)  varP4_String.setCharAt(i + 8,'0');

    else  varP4_String.setCharAt(i + 8,'1');

  }

  varString = "";

  varString = varP0_String + varP1_String + varP2_String + varP3_String + varP4_String;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  digitalWrite(pinSerialOut, LOW);

  //Serial.print("L");

  delay(320);

  digitalWrite(pinSerialOut, HIGH);

  //Serial.print("H");

  delay(65);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println("L");

  delayMicroseconds(900);

  varTemp_int = varString.length() - 1;

  for (int i=0; i <= varTemp_int; i++)  {

    varCharRecover_char = varString.charAt(i);

    //Serial.write(varCharRecover_char);

    digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(225);

    digitalWrite(pinSerialOut, LOW);

    delayMicroseconds(225);

    if (varCharRecover_char == '0')  digitalWrite(pinSerialOut, HIGH);

    delayMicroseconds(1800);

  }

  digitalWrite(pinSerialOut, HIGH);

  //Serial.println("");

  //Serial.println("End");

}

void fxPlayRB()  {

  //Serial.print("Building ON message with zone: ");

  //Serial.println(varZone);

  arrayOn_Byte[7] = varZone;

  arrayOn_Byte[9] = varZone + 66;

  delay(150);

  digitalWrite(A5, HIGH);

  delay(100);

  digitalWrite(A5, LOW);

  if (varTimeOn == 1)  {  // Send ON message

    for (int ii=0; ii <= 9; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOn_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOn_Byte[10],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  else  {  // Send OFF Message

    for (int ii=0; ii <= 6; ii++)  {

      for (int i=7; i >= 0; i--)  {

        if (bitRead(arrayOff_Byte[ii],i) == 1)  {

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timeaftertrans);

          //Serial.print("1");

        }

        else  {

          digitalWrite(pinSerialOut, LOW);

          delayMicroseconds(timetiltrans);

          digitalWrite(pinSerialOut, HIGH);

          delayMicroseconds(timeaftertrans);

          //Serial.print("0");

        }

      }

      //Serial.print(" ");

    }

    for (int i=7; i >= 1; i--)  {

      if (bitRead(arrayOff_Byte[7],i) == 1)  {

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timeaftertrans);

        //Serial.print("1");

      }

      else  {

        digitalWrite(pinSerialOut, LOW);

        delayMicroseconds(timetiltrans);

        digitalWrite(pinSerialOut, HIGH);

        delayMicroseconds(timeaftertrans);

        //Serial.print("0");

      }

    }

  }

  delayMicroseconds(timeaftertrans);

  digitalWrite(pinSerialOut, LOW);

  //Serial.println();

  //Serial.println("End");

}

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates