Help pls about Serial.write

Hey guys!

Come help me out about the Serial.write(); i want to write an array containing a hexadecimal data,

byte query[] = {0xF5, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x0C^0x00^0x00^0x00^0x00, 0xF5);

for(i=0, i<8, i++){
Serial.write(query[i]);
serial.println(query, HEX);
}

but the data duino sending is a decimal, not HEX.

I also tried this one but an error occurs.

byte query[] = {0xF5, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x0C^0x00^0x00^0x00^0x00, 0xF5);

for(i=0, i<8, i++){
Serial.write(query[i], HEX);
serial.println(query, HEX);
}

Pls help me. Give some examples so I can understand clearly

Moderator edit: Code rendered legible by the removal of italics, and the addition of CODE TAGS.

but the data duino sending is a decimal, not HEX.

No, the data is sent as binary. All data within a processor, or moving through a serial port, is binary. Hex, decimal, ASCII, etc, are all just human-readable interpretations of binary. How the receiver interprets the data defines how you see it. What are you using to view the data?

The data displaying in the serial port is HEX, but my problem is how can I write an array containing HEX data.

Thank you for reminding about ASCII, HEX, DEC etc.

byte query[] = {0xF5, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x0C^0x00^0x00^0x00^0x00, 0xF5);

for(i=0, i<8, i++){
Serial.write(query[i], HEX); WHEN I PUT THE "HEX" HERE AN ERROR OCCURS
serial.println(query, HEX);
}

Moderator edit: More CODE TAGS

The array contains data. It is stored in binary, not hex, the 0x prefix is for the benefit of humans.

Look up the Serial.write reference page. If there is a second parameter, it represents the length of the data buffer in the first parameter. HEX is not an appropriate value.

byte query[] = {0xF5, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x0C^0x00^0x00^0x00^0x00, 0xF5);

Why all the bitwise Oring with zero in here?

About the bitwise XOR, i'm just checking the total data.

What do you mean?

can you give some examples, can you point it out pls.

0x0C^0x00^0x00^0x00^0x00

What is this doing?

Oh, it is a certain command, CHK, i'm working with a fingerprint scanner i nid to send a 8bit packet data.

the bitwise is to check if the data inside the data packet is correct,

about the serial.write, if I use buf or len can it do th job,

It should be able to. It's down to the receiving end to interpret the data correctly.

for(i=0, i<8, i++){
Serial.write(query[i], HEX);
serial.println(query, HEX);
}

If you're going to post code, please post the ACTUAL code you're having problems with, not just something you made up.

Here it is, sorry about that, I'm just seeking help,

#define ACK_SUCCESS 	0x00 		//operation success
#define ACK_FAIL 	0x01 		//operation fail
#define ACK_FULL 	0x04 		//memory full
#define ACK_NOUSER 	0x05 		//user does not exist
#define ACK_USER_EXIST 	0x07 		//user already exists
#define ACK_TIMEOUT 	0x08 		//time out in fingerprint collection


unsigned char ver[8] = {0xF5, 0x26, 0x00, 0x00, 0x00, 0x00, 0x26^0x00^0x00^0x00^0x00, 0xF5};
char standby[8] = {0xF5, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x2C^0x00^0x00^0x00^0x00, 0xF5};
char readto[8] = {0xF5, 0x2E, 0x00, 0x00, 0x01, 0x00, 0x2E^0x00^0x00^0x01^0x00, 0xF5};
char recong[8] = {0xF5, 0x28, 0x00, 0x05, 0x01, 0x00, 0x28^0x00^0x05^0x01^0x00, 0xF5};
char enroll[8] = {0xF5, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x2D^0x00^0x00^0x00^0x00, 0xF5};
byte match[8] = {0xF5, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x2C^0x00^0x00^0x00^0x00, 0xF5};


int data1 = 0;
int button = 2;
char fpr[10],z;
unsigned int counter[2];

void setup()
{  
  Serial.begin(19200);
}
void loop()
{
  int i;
  byte val;
  
   while(Serial.available()>0){
      for (i=0 ; i<8 ; i++){
      Serial.write (match[i]);  // query [ x ] is what pulls up the 0x55, 0xAA, etc as 'i' goes from 0,1,2,3 ...
      Serial.print(match[i]);
      }
    }
  delay(1000);
  Serial.println("--");
  
}

Moderator edit: CODE TAGS again.

Can someone help me please, a decent person that doesn't make a fuss about his knowledge about the arduino, even the moderator here is a bag of air.

A teacher that point outs your mistake, not make a big deal out of it.

papyrus12:
Can someone help me please, a decent person that doesn't make a fuss about his knowledge about the arduino, even the moderator here is a bag of air.

A teacher that point outs your mistake, not make a big deal out of it.

That is not the way to go about asking for help. Good luck with your project.

even the moderator here is a bag of air.

Nice.
I pointed out that the code you posted couldn't possibly compile, thereby potentially wasting other people's time.
I added CODE TAGS when you couldn't be bothered.

Good luck with your project.

papyrus12:
the bitwise is to check if the data inside the data packet is correct,

That's nonsense, sorry.

If you don't like the moderators here, go to another forum.

http://www.avrfreaks.net/

If you don't like the moderators here, go to another forum.

http://www.avrfreaks.net/

I was going to suggest the same, but I'm fundamentally opposed to bloodsports.