ดิจิทัลเอาท์#

การแนะนำ#

คลาส digital_out ช่วยให้ EXP Brain สามารถส่งสัญญาณดิจิทัลไปยังส่วนประกอบภายนอก เช่น 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 — ตั้งค่าระดับสัญญาณของพอร์ต Digital Out 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#

ตั้งค่าระดับสัญญาณของพอร์ต 3 สายที่เลือกไว้

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);