Comparing a byte to a constant int

I am working on RF communication project.

I want to compare the received byte into a constant integer,

what command should I use in Arduino ?

Can the integer be greater than 255? Otherwise, make it a byte.

Or simply this: if (recvd_byte == comp_int) ...

Again, as long as the int is less than 255 you should be fine. You can put in a cast if you are paranoid.

This is the code with the comparison, but “message is not displayed at the serial monitor”, even though 3 is received.

for(i=0; i<8; i++){
          bitWrite(data_in, i, 1);
          bitWrite(data_in, i, 0);
        if (data_in == 3) {Serial.println("message"); m=1; delay(1000);}

Did you mean '3'?


Seems to indicate you expect a character, isn't it?

I changed the code ad below. Now it's working. Thanks for the help.

data_in == '3'/code]

I want to make sure the received bytes are 3 and 0. I am receiving these information and the values of the assigned variables m and n are updated to "1"

However, when I use these two variables to display a text at the serial monitor. Nothing is displayed. Please advise.

if (data_in == '6') {Serial.println("m=1"); m=1;}
        if (data_in == '0') {Serial.println("n=1"); n=1;}
        if (m == 1 && n==1) {Serial.println("message");  delay(1000); PortOne.listen(); PortOne.print(message);delay(5000);}/code]

FutureEngineer: I want to make sure the received bytes are 3 and 0.

3 and 0 you say?

if (data_in == '6')

I want to make sure the received bytes are 3 and 0.

Well, 6 and 0, anyway. Does it matter that the bytes are 6 then 0, rather than 0 then 6, which your current code allows?