if (Serial)

[Serial]

説明

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


Language Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

コメントする

上部へスクロール