ok, this is what i have here for a headache. the coding is simple, however for some reason if i type the ff commands into the serial console it works, but if i hook up the AU40Z ptz controller to it, it will do nothing. i have Ultra Serial Port monitor, and a few dozen other serial spy/monitoring programs and they all show that the ptz controller is outputting data in hex. the Arduino Pro i have seems to convert the data from the ptz controller to the extended ascii codes only. i have tried several different things, hex, bin, dec, ect along with different placement of int and byte ect.. but end up with the arduino no reading it or interpreting it correctly. i have been googling possible reasons and solutions for a few months now, but im stumped. i know it is something so simple but i feel i have been at this for too long and have grown blind to something obvious.
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>=14)
{
String msg;
for(int i = 0; i<14; i++)
msg += char(Serial.read());
delay(500);
Serial.println(msg);
if(msg.equals("FF 01 00 20 00 00 21")) //TELE FF 01 00 20 00 00 21
{
Serial.write("0xA0 0x2 0x5 0x58 0xFF");
}
else if(msg.equals("FF 01 00 00 00 00 01")) //STOP
{
Serial.write("0xA0 0x2 0x7 0x57 0xFF");
}
else if(msg.equals("FF 01 00 40 00 00 41")) //WIDE
{
Serial.write("0xA0 0x2 0x6 0x58 0xFF");
}
else if(msg.equals("FF 01 01 00 00 00 02")) //NEAR
{
Serial.write("0xA0 0x2 0x6 0x58 0xFF");
}
else if(msg.equals("FF 01 00 80 00 00 81")) //FAR
{
Serial.write("0xA0 0x2 0x6 0x58 0xFF");
}
}
}