how to send 2 bytes of data at the sametime in serialwrite

Hi,

I am reading the data from the sensor encoder which consists of 2 bytes. I need to send 2 bytes of at the same time in serial write .Can you plz tell me how to send the 2 bytes of data at a time.

e.g. Serial.write( ptr, len)

Did you read the help?

I need to 2 bytes of integer data at the same time to Arduino ...which I am reading the the 2 bytes of same data in c++ using qt softwre...I tried that way it is not working.
int encoder_in = 3;
volatile unsigned int pulses = 0;
int relay =8;
char sta;
float var=0;
//int Reset = 4;
void(* resetFunc) (void) = 0;

void count() {

// This function is called by the interrupt

pulses++;

}

void setup() {

pinMode(encoder_in, INPUT_PULLUP);
pinMode(relay,OUTPUT);
attachInterrupt(1, count, RISING);
Serial.begin(9600);
digitalWrite(relay,LOW);
// digitalWrite(Reset, HIGH);
//pinMode(Reset, OUTPUT);
}

void loop()
{
if(Serial.available()>0)
{

//Serial.print("came inside");
sta=Serial.read();
Serial.print(sta);
if(sta=='b')
{
// Serial.print("motior is on");
digitalWrite(relay,HIGH);
}
if(sta=='a')
{
// Serial.print("motior is off");
digitalWrite(relay,LOW);

}
if(sta=='c')
{
//Serial.print("Resetting");
//digitalWrite(Reset, LOW);
resetFunc();

}
}
//Serial.print("pulses=");

// Serial.write(pulses);

Serial.print(",");
delay(220);

}

Why not use Serial.print() and write you PC program so it interprets the received data as text?

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor. See How to use the Forum

...R

chandanaraju:
I need to 2 bytes of integer data at the same time to Arduino ...which I am reading the the 2 bytes of same data in c++ using qt softwre...I tried that way it is not working.

If you're writing a Windows C++ program, you can use this library "ArduSerial" to interface with COM ports instead of QT.