Hi, glad you did it. Of course there's a better way, using the serial message capability of the OMNI II: you can send any of the messages that can be displayed over one of the serial port on board, then you can have the Arduino monitor that serial port and behave accordingly.
The only downside is that you'll need 2 serial ports both on the console and the Arduino; all OMNI PRO consoles come with 2 or 3 serials, so if you haven't any third party device using the ports you should be fine, for Arduino you must use a MEGA, that has 3 serial on board, maybe a Leonardo that has 2, or simply use a SoftSerial library, that should be fast enough.
That being said you must first set the serial on the console to the PRO-LINK protocol via PC-ACCESS.
Then program the console so that when your trigger activates, it sends a message to SERIALX (where X is the serial port you're using) - check out the pro link protocol on HAI documentation.
On Arduino side, my code goes like this:
some notes:
- The messages I send are in the form HAI1, HAI2, HAI3, etc., but they could be anything; as a matter of fact they are parsed only partially, when it gets an "H" it jumps to the number at the end;
- I use the messages to trigger a function that pushes messages on my mobile devices when certain situations happen, but you could do anything you want;
//HAI PRO-link protocol data arrays
byte byteReadPro;
byte HAI_PRO_messageID; //6 chars at max for Hai triggers: HAIXXX, but can be longer if sending HAI console messages
[...]
if (Serial2.available()>0){
Serial.println("Data available on Serial2");
if (readProLink()>0){ //the function returns the HAI message number
//PARSE the HAI Message and do things
switch (HAI_PRO_messageID){
case 1:
sendToPushingBox(DEVID1);
break;
case 2:
sendToPushingBox(DEVID2);
break;
case 3:
sendToPushingBox(DEVID3);
break;
case 4:
sendToPushingBox(DEVID4);
case 5:
sendToPushingBox(DEVID5);
break;
}//END switch
}//END if parseProLink
}//END if Serial2.avaliable
byte readProLink() {//gets the command form Serial2 coming in the form HAIXXX (in fact it reads any message like HwhateverXXX)
//static byte dataBufferIndex2=0;
static byte messageSize2=DATABUFFERSIZE; //length of the message, at the beginning it can be the maximum value
static boolean storeVal2=false; //flag to define if the incomingbyte has to be put in the array
static boolean ended2 = false; //flag for end of message
char incomingChar;
while(Serial2.available()>0){
//Serial.print("Receiving data on Serial2 Prolink: ");//DEBUG
//Serial.println(dataBufferIndex2);
incomingChar = Serial2.read();//put data in incomingbyte variable
Serial.print("Data received: ");
Serial2.println(incomingChar);
if(incomingChar=='H' ){//if it's H it should be the beginning of the HAIXXX command
HAI_PRO_messageID = Serial2.parseInt();
Serial.println();
Serial.print("HAI PRO Message received: ");
Serial.println(HAI_PRO_messageID);
return HAI_PRO_messageID;
}//END if
}//END while Serial2.available
return 0;
}//END readProLink()
I also have to mention the "easier" way, that is having the HAI to activate a relais connected with one of the Arduino inputs, but I prefer the serial solution, that also requires less space.