How to send mutliple byte line in one command

Hi,

I have this LCD that requires you to send a serial command to initiliaze and execute certain funtions. For example to change the brightness of the backlite you have to enter 0x7C 0x02 0x32. The first byte tells the LCD to expect a command. The second one is the command and the third is the value. So, what I have been doing is sending each byte as a single Serial.print to the LCD and this sort of works. I woudl like to know if there is a better way to do this?

Here is my code example : Serial.print(0x7C,BYTE); // Command prep code Serial.print(0x02, BYTE); // Set duty cycle Serial.print(0x32, BYTE); // 50% duty

Here is what I would like to do that does not work.

Serial.print(0x7C, 0x02, 0x32, BYTE);

How can I do this with 1 line of code?

Thanks,

MadDawg

See this: http://www.arduino.cc/playground/Main/StreamingOutput :)

Try

Serial.print("\x7C\x02\x32");

You cannot send a byte 0x00.

Actually the compiler generates the sequence of bytes:

0x7C,0x02,0x32,0x00

here the last 0x00 byte is interpreted as the end of the charcter string.

Magnus

You cannot send a byte 0x00.

Correction: You cannot send a byte 0x00 ('\0') as part of a string

Thanks guys. Worked great. And understand not being able to send 0x00 in a string and send seperatly as needed.

Appricate the help,
Now just neeed to learn more anout C coding and all. Need to figure out how to talk to the Wiishiled and a Serial LCD at the same time.

MadDawg

Great.

For the record, if you do not want to handle 0x0 bytes separatly you can use an array of unit8 values and Serial.write:

uint8_t cmd[]={0x7C,0x02,0x32};
Serial.write(cmd,3);

Correction: You cannot send a byte 0x00 (’\0’) as part of a string

So, this should not work then? :wink:

Serial.write((byte *)"<<\x00>>",5);

Thanks. I would like to expand on my request. I appolgize, but new to programing. So I have this large LCD and want to print to the screen via serial commands a Graphic logo using and array of coordinates in this format X1,Y1,X2,Y2. I used excel to create all the coordinates and convert them into HEX numbers as this is what the Serial LCD expects. Now I would like to create some loop to draw the image from the array . The serial command code sequence needs to format like this 0x7C,0x0C,0xX1,0xY1,0xX2,0xY2,0x01. The data is in groups of 4 and has 163 sets of coordinates.

With all your experience how does this work? And please explain it out for me by line so I can understand the process if you could so kindly as I want to be able to learn from it.

Again Thanks,

MadDawg