Correct my syntax please?

This is a deliberately blocking test function which is why it doesn't matter about delays. I am sending the main code three times and following it with an "End of transmission" code 0x5121. That all works.

The volume control should not have the EOT code sent, so I wrote a little If test which stops the EOT being transmitted at all for some reason. Being at work I KEEP being interrupted >:( so can't see the wood for the trees. Could someone advise me where I have cocked it up please?

// ************************ Cycle through Sony IR codes transmit ********************************
void proc_transmitTest() {
  // Uses A6 to sense whether to engage test mode. If high, normal. Low = run test on continuous loop.

  unsigned long endData = 0x5121; // Release code sent at the end of the burst.

  for (int x = 0; x < 21; x++) {
    unsigned long tData = (Sony [x]); //Look up the next code from the array 'Sony'.

    for (int i = 0; i < 3; i++) {
      irsend.sendSony(tData, 15); // Send key data three times
      Serial.print(F("sendSony(0x"));
      Serial.print(tData, HEX);
      Serial.println(F(", 15)"));
      delay(40);
    }

    tData++;
    delay(1500);
//    if ((tData)==!0x2421 && !0x6421) {  // If volume up or down, don't send EOT
    irsend.sendSony(endData, 15); // Send release code once
    Serial.print(F("sendSony(0x"));
    Serial.print(endData, HEX);
    Serial.println(F(", 15)"));
    delay(40);
//    }
    delay(5000); //5 second delay between each signal burst
  }
}
if ((tData)==!0x2421 && !0x6421)^

is odd

I guess it should be

if (   ((tData) != 0x2421)  && ((tData) != 0x6421)    )

best regards Stefan

Could someone advise me where I have cocked it up please?

Cock up #1 is not posting a complete sketch so that the problem can be seen in context

    tData++;

Why? It's not going to make checking the value of tData any easier.

 if ((tData) == !0x2421 && !0x6421)

The '!' operator is a LOGICAL NOT. Since "0x2421" is not 0 it is 'true'. Therefore, "!0x2421" is 'false' or 0. Same for "!0x6421" evaluating to false/0.

That makes the expression equivalent to:

 if ((tData == 0) && false)

That will always be 'false'.

When you want the comparison "is not equal to" you use the '!=' operator:

 if (tData != 0x2421 && tData != 0x6421)

john you are right thanks for correcting

StefanL38:

if ((tData)==!0x2421 && !0x6421)^

is odd

I guess it should be

if (   ((tData) != 0x2421)  && ((tData) != 0x6421)    )

best regards Stefan

Thanks for that Stefan.

UKHeliBob:
Cock up #1 is not posting a complete sketch so that the problem can be seen in context

I beg to differ. I was asking only about the correct syntax of one line, not for help with any other aspect of the program. If I were to post it all, it would be as an attachment and it would not compile anyway without the local libraries and a modified public library. So in this case, although I understand your point, we will have to agree to disagree.

johnwasser:
When you want the comparison "is not equal to" you use the '!=' operator:

 if (tData != 0x2421 && tData != 0x6421)

Thanks John. That has sorted out my confusion.

After looking at my coding again and using the correct syntax this time, I noticed that I was using a sledgehammer to crack a nut. The value of 'X' was all I needed to test for!

Thanks again for everyone's kind and helpful advice.

I beg to differ. I was asking only about the correct syntax of one line, not for help with any other aspect of the program.

I agree entirely with your comments about posting a large sketch with library dependencies but that was not what I suggested. You posted an isolated function and you could have posted a small sketch incorporating that function which illustrated the problem that you were having by calling the function with appropriately valued variables