Parsing data packets

int flag = 0;

flags are typically boolean - something happened/needs to be done, or is didn't/doesn't.

if((digitalRead(LED1))==HIGH){ digitalWrite(LED1,LOW); }
The highlighted parentheses are not needed. Some spaces ( == ) and () {) are. No recognized style calls for the } to be on the same line as anything else. There are plenty of styles to choose from. Inventing your own isn't necessary.

  flag++;

should be

  flag = true;
  if(flag == 1){

should be:

   if(flag)
   {
    flag = 0;

should be

     flag = false;

And, finally, flag is a lousy name for the variable. The value, true or false, means that an event occurred, or didn't. The name of the variable should reflect that.

Otherwise, yes, that is what I was driving at.

Robin2:
I can't help feeling that people are assuming @Houser636 knows a great deal more than s/he actually does.

If I'm right it would do no harm to be a little less critical.

Some people just can't help themselves. 8)

http://forum.arduino.cc//index.php?topic=191618.msg1416938#msg1416938

If a kid asks where rain comes from, I think a cute thing to tell him is "God is crying." And if he asks why God is crying, another cute thing to tell him is "Probably because of something you did." - PaulS

LOL zoomkat, this made me laugh.

I didn't get my feelings hurt, and appreciate PaulS advice.

LOL zoomkat, this made me laugh.

Well, it's crap, and zoomkat knows it. He makes it look like a quote, and I've never said anything like that.