Sorry, your question and code make no sense at all. You test for serial byte(1), which is the second byte in the buffer, before you even know if you have read TWO bytes.
Also, "false" means the numeric value is ZERO, all other values will return TRUE!
What are you REALLY trying to do?
Paul
Snippets of code often leave out important information. That is why we request that you post the whole code. That if statement will not compile. See the if structure reference for the syntax.
So you have an external device that is sending serial data to the mystery Arduino? What is the device? What is it sending (ASCII, binary)? Provide a sample of the serial data.
What do you mean by "position 1 of serial_byte"? Do you mean the first bit of that byte? Or do you mean bit number 1, which is the second bit because bits are numbered from 0. Or do you mean something else?
Yes, this.
the value of the bit in position 1 (the second bit).
I need to make a comparison using that bit.
if this bit is true (> 0) it does one thing. if it is false (<0) make another one.
Everyone else doesn't care.
byte ourByte = 0b00000010;
void setup()
{
Serial.begin(115200);
// read the second from the right bit (bit 1) of the byte ourByte
Serial.print("bit 1 of ourByte = ");
Serial.println(bitRead(ourByte, 1));
}
void loop()
{
}