數位輸出#
介紹#
digital_out 類別可讓 V5 主控模組向外部組件(例如 LED、繼電器或其他電子設備)發送數位訊號。它可以發送高電平訊號(5 伏特)或低電平訊號(0 伏特)。
類別建構函數#
digital_out(
triport::port &port );
類別析構函數#
銷毀 digital_out 物件並釋放相關資源。
~digital_out();
參數#
範圍 |
類型 |
描述 |
|---|---|---|
|
|
數位輸出設備連接的 3 線端口,寫成 |
例子#
// Create the digital_out instance on 3-Wire Port A
digital_out DigitalOutA = digital_out(Brain.ThreeWirePort.A);
成員功能#
digital_out 類別包含以下成員函數:
set— 將 3 線數位輸出埠的訊號電平設定為高或低。
在呼叫任何 digital_out 函數之前,必須先建立一個 digital_out ,如下所示:
/* This constructor is required when using VS Code.
Digital output configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create the digital_out instance on 3-Wire Port A
digital_out DigitalOutA = digital_out(Brain.ThreeWirePort.A);
set#
設定所選三線連接埠的訊號電平。
Available Functionsvoid set(
bool value );
範圍 |
類型 |
描述 |
|---|---|---|
|
|
是否發送高電位或低電平訊號: |
此函數不傳回值。
Examples// Set the Digital Output to true
DigitalOutA.set(true);
// Set the Digital Output to false
DigitalOutA.set(false);