How sent a hex command thougth TX with arduino leonardo

I have an arduino leonardo and I want send a command to a camara in Hex (camera has a RS232 reciver (RX)) each time one of my PIRs close circuit (one hex for each PIR) so the camera rotate to a preset possition…

the hexs are {0x81,0x01,0x04,0x3F,0x02,0x00,0xFF} PIR 1
{0x81,0x01,0x04,0x3F,0x02,0x01,0xFF} PIR 2
{0x81,0x01,0x04,0x3F,0x02,0x02,0xFF} PIR 3

I tried

int PIR1 = 8;
int PIR2 = 9;
int PIR3 = 10;

void setup()
{
   pinMode(PIR1 INPUT); 
   pinMode(PIR2 INPUT);
   pinMode(PIR3 INPUT);
   Serial1.begin(9600);    // to start port 1 in arduino leonardo(TX). this one I connect it to the RX port in the camera
   
}

void loop()
{
   if(digitalRead(PIR1) == HIGH) 
   {
     byte arrayBytes [] = {0x81,0x01,0x04,0x3F,0x02,0x00,0xFF};
     Serial.write(arrayBytes, 7);  
  
   if(digitalRead(PIR2) == HIGH) 
   {
     byte arrayBytes [] = {0x81,0x01,0x04,0x3F,0x02,0x01,0xFF};
     Serial.write(arrayBytes, 7);  
   
   if(digitalRead(PIR3) == HIGH) 
   {
     byte arrayBytes [] = {0x81,0x01,0x04,0x3F,0x02,0x02,0xFF};
     Serial.write(arrayBytes, 7);  
   }

Posting in the wrong place, and bumping the thread after 15 minutes will get you banned. Do NOT do that again.

jucarbar:
I have an arduino leonardo and I want send a command to a camara in Hex

Can you provide a link to the datasheet that specifies this?

I would be very surprised if the camera expects to get ascii characters representing hex values - for example the characters 0 x 3 F

...R

Sorry and thank you for the answer.
I am new with arduino and I dont know if my objetive is possible.

  1. I can control the camera through my computer using a usb to 232 cable converter, using realterm software; with HEX commands.
  2. I dont know if is possible send the same commands through the port 1 (TX) of arduino leonardo?.

jucarbar:
I am new with arduino and I dont know if my objetive is possible.

  1. I can control the camera through my computer using a usb to 232 cable converter, using realterm software; with HEX commands.
  2. I dont know if is possible send the same commands through the port 1 (TX) of arduino leonardo?.

I think we already knew this.
Please provide the information requested in Reply #2

...R