RS232 projector remote

Hello, i try without success to change my projector from a vivitek to a nec
I have a very simple arduino program to do that.
For my vivitek i use Serial.println("~PN"); for ON command
For a sanyo i use Serial.println("C00");

For a nec projector the ON command is 02h 00h 00h 00h 00h 02h
I have tried Serial.println("02 00 00 00 00 02"); and many other things but without success.

My serial rate are right.
When i read the string with a sniffer i received the same string but not in this form.

Have you a idea to send exactly 02 00 00 00 00 02 in this form?

Thanks

Denis

And excuse my poor english, i'm french speaker

For a nec projector the ON command is 02h 00h 00h 00h 00h 02h

So, 6 bytes of 2, 0, 0, 0, 0, 2.

I have tried Serial.println(“02 00 00 00 00 02”);

I can’t imagine why you think that sending a string, when the device expects 6 bytes, is going to accomplish anything.

Create a 6 element byte array, with the above values, and Serial.write() the array.

You want to send : 02 00 00 00 00 02 from UNO to your remote Projector using RS232 Protocol. You expect that the Projector should receive exactly the same array.

1. The available commands of RS232 Protocol to transfer data are:
Serial.print();
Serial.write():

2. Look at the following Table:

Command Executed        UNO Sends                                           Projector Receives  
Serial.print("A");            0x41 (ASCII Code of A)                         0x41

Serial.print("0");            0x30 (ASCII Code of 0)                          0x30

Serail.print("02");           0x30  (ASCII Code of 0)                         0x30
                                    0x32 (ASCII Code of 2)                          0x32

Serial.write(0x02);          0x02  (8-bit natural binary 00000010)      0x02

3. Based on Post#1, we can write the following codes to transmit : 02 00 00 00 00 02

byte dataArray[6] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x02};
for(int i = 0; i<6; i++)
{
   Serial.write(dataArray[i]);        //do not expect to see the values in your local Serial Monitor
}

Even simpler:

byte dataArray[6] = { 0x02, 0xx00, 0x00, 0x00, 0x00, 0x02};
   Serial.write(dataArray, 6);

GolamMostafa:
You want to send : 02 00 00 00 00 02 from UNO to your remote Projector using RS232 Protocol. You expect that the Projector should receive exactly the same array.

1. The available commands of RS232 Protocol to transfer data are:
Serial.print();
Serial.write():

2. Look at the following Table:

Command Executed        UNO Sends                                           Projector Receives  

Serial.print(“A”);            0x41 (ASCII Code of A)                         0x41

Serial.print(“0”);            0x30 (ASCII Code of 0)                          0x30

Serail.print(“02”);           0x30  (ASCII Code of 0)                         0x30
                                   0x32 (ASCII Code of 2)                          0x32

Serial.write(0x02);          0x02  (8-bit natural binary 00000010)      0x02




**3.** Based on Post#1, we can write the following codes to transmit : 02 00 00 00 00 02


byte dataArray[6] = { 0x02, 0xx00, 0x00, 0x00, 0x00, 0x02};
for(int i = 0; i<6; i++)
{
  Serial.write(dataArray[i]);
}

Or, if you’re not being paid by the line-of-code

const byte dataArray[6] = { 0x02, 0xx00, 0x00, 0x00, 0x00, 0x02};
   Serial.write(dataArray, sizeof (dataArray));

TolpuddleSartre:
Or, if you're not being paid by the line-of-code

const byte dataArray[6] = { 0x02, 0xx00, 0x00, 0x00, 0x00, 0x02};

Serial.write(dataArray, sizeof (dataArray));

PaulS:
Even simpler:

byte dataArray[6] = { 0x02, 0xx00, 0x00, 0x00, 0x00, 0x02};

Serial.write(dataArray, 6);

I would prefer @Pauls (only one character instead of 18)?

SOLVED and thanks to everybody

GolamMostafa:
I would prefer @Pauls (only one character instead of 18)?

Spoken like a true noob.

GolamMostafa:
I would prefer @Pauls (only one character instead of 18)?

If the size of the array changes, the hardcoded value will be wrong. The sizeof() method will not.

As long as you are careful, there won't be a problem. But, one mistake...

Another question. I try a Optoma projector to check my remote.

The string for ON is ~XX00 1 or 7E 30 30 30 30 20 31 0D

I try :

byte dataArray[8] = {0x7e,0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x0d};
Serial.write(dataArray, 8);

And nothings append.

Have you a idea

Many Thanks

The string for ON is ~XX00 1 or 7E 30 30 30 30 20 31 0D

The ASCII value for the ~ is 0x7E. The ASCII value for the space is 0x20. The ASCII value of the 1 is 0x31. The character whose ASCII value is 0x30 is the ‘0’.

So, the HEX values you show do NOT correspond to the string that you show.

It's my error the good string is ~0000 1
In my exemple XX was the ID of projector, ID 00 is for all projector

It's my error the good string is ~0000 1

So, why not just print "~0000 1"?

I have try without success.

I have tried Serial.println("~0000 1");
or Serial.print("~0000 1");
or Serial.write("~0000 1");
but nothing

When i send :
byte dataArray[8] = {0x7e,0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x0d};
Serial.write(dataArray, 8);
I receive on sniffer : ~0000 1 ( that’s good)
But no response from projector

But if i send the same string 7E 30 30 30 30 20 31 0D from a laptop, the projector goes on without problem

But if i send the same string 7E 30 30 30 30 20 31 0D from a laptop, the projector goes on without problem

How are you sending data from the laptop?

The string "7E 30 30 30 30 20 31 0D" is nowhere near the same as the string "~0000 1" or the byte array 0x7e, 0x30, 0x30, 0x30, 0x30, 0x20, 0x31, 0x0d.

from a nice free program call comtools from sonelec, french programmer

denis114:
from a nice free program call comtools from sonelec, french programmer

Open source, or executable only? Link?

old program executable :Logiciels - Freewares - ComTools

I think the problem is the space in :"~0000 1"
because when i send it, i receive ~00001 on the computer

How to add a "space" ?

denis114:
I think the problem is the space in :"~0000 1"
because when i send it, i receive ~00001 on the computer

How to add a "space" ?

You add a space to a string by pressing the space key.

It really would be helpful if you explained how you are receiving this data. However it is, that is the process that is loosing the space.