數位輸出#

介紹#

digital_out 類別可讓 V5 主控模組向外部組件(例如 LED、繼電器或其他電子設備)發送數位訊號。它可以發送高電平訊號(5 伏特)或低電平訊號(0 伏特)。

類別建構函數#

digital_out(
  triport::port &port );

類別析構函數#

銷毀 digital_out 物件並釋放相關資源。

~digital_out();

參數#

範圍

類型

描述

port

triport::port &

數位輸出設備連接的 3 線端口,寫成 Brain.ThreeWirePort.X 或 ExpanderName.X,其中 X 是端口字母(例如, Brain.ThreeWirePort.A 或 Expander1.A)。

例子#

// 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 Functions
void set(
  bool value );

Parameters

範圍

類型

描述

value

bool

是否發送高電位或低電平訊號: true 發送高電平訊號(5V), false 發送低電平訊號(0V)。

Return Values

此函數不傳回值。

Examples
// Set the Digital Output to true
DigitalOutA.set(true);

// Set the Digital Output to false
DigitalOutA.set(false);