if (Serial)

Description

Indicates if the specified Serial port is ready.

On all 86Duino boards, if (Serial) indicates whether or not the USB CDC serial connection is open. For all other instances of real serial ports (UART), including if (Serial1), this will always returns true.

Syntax

All boards:

if (Serial)
if (Serial1)

86Duino One specific:

if (Serial2)
if (Serial3)
if (Serial485)

86Duino EduCake specific:

if (Serial2)
if (Serial3)
if (Serial232)

Parameters

none

Returns

boolean : returns true if the specified serial port is available. This will only return false if querying the USB CDC serial connection before it is ready.

Example

void setup() {
 //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
}

void loop() {
 //proceed normally
} 

See also

Serial
available()
begin()
end()
find()
findUntil()
flush()
parseFloat()
parseInt()
peek()
print()
println()
read()
readBytes()
readBytesUntil()
setTimeout()
write()
serialEvent()


Language Reference Home

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.