ไฟแสดงสถานะ LED#

การแนะนำ#

คลาส led ช่วยให้ V5 Brain สามารถเปิดหรือปิดไดโอดเปล่งแสง (LED) ที่เชื่อมต่ออยู่โดยใช้พอร์ต 3 สาย

ไฟแสดงสถานะ LED สีเขียว VEX V5

คอนสตรัคเตอร์คลาส#

led(
  triport::port &port );

ตัวทำลายคลาส#

ทำลายวัตถุ led และปล่อยทรัพยากรที่เกี่ยวข้อง

virtual ~led();

พารามิเตอร์#

พารามิเตอร์

พิมพ์

คำอธิบาย

port

triport::port &

พอร์ต 3 สายที่เชื่อมต่อกับไฟแสดงสถานะ LED เขียนเป็น Brain.ThreeWirePort.X หรือ ExpanderName.Xโดยที่ X คือตัวอักษรของพอร์ต (ตัวอย่างเช่น Brain.ThreeWirePort.A หรือ Expander1.A)

ตัวอย่าง#

// Create an led instance in Port A
led LEDA = led(Brain.ThreeWirePort.A);

ฟังก์ชันสมาชิก#

คลาส led ประกอบด้วยฟังก์ชันสมาชิกต่อไปนี้:

  • on — เปิดไฟแสดงสถานะ LED ที่ระบุ

  • off — ปิดไฟแสดงสถานะ LED ที่ระบุ

ก่อนเรียกใช้ฟังก์ชันสมาชิก led ใดๆ จะต้องสร้างอินสแตนซ์ led ก่อน ดังแสดงด้านล่าง:

/* This constructor is required when using VS Code.
LED Indicator configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create an led instance in Port A
led LEDA = led(Brain.ThreeWirePort.A);

on#

เปิดไฟแสดงสถานะ LED ที่ระบุไว้

Available Functions
void on();

Parameters

ฟังก์ชันนี้ไม่รับพารามิเตอร์ใดๆ

Return Values

ฟังก์ชันนี้ไม่ส่งค่ากลับ

Examples
// Turn on the LED
LEDA.on();

// Wait 2 seconds
wait(2, seconds);

// Turn off LED
LEDA.off();

off#

ปิดไฟแสดงสถานะ LED ที่ระบุไว้

Available Functions
void off();

Parameters

ฟังก์ชันนี้ไม่รับพารามิเตอร์ใดๆ

Return Values

ฟังก์ชันนี้ไม่ส่งค่ากลับ

Examples
// Turn on the LED
LEDA.on();

// Wait 2 seconds
wait(2, seconds);

// Turn off LED
LEDA.off();