สมอง#
การแนะนำ#
หมวดหมู่การตรวจจับคลื่นสมอง VEX IQ (รุ่นที่ 2) นำเสนอวิธีการโต้ตอบกับปุ่มต่างๆ ของสมองและแบตเตอรี่ที่เชื่อมต่ออยู่
หน้านี้ใช้ชื่อ Brain เป็นตัวอย่างว่า brain กรุณาแทนที่ด้วยชื่อที่คุณกำหนดเองตามต้องการ
ด้านล่างนี้คือรายการวิธีการทั้งหมด:
การกระทำ — โต้ตอบกับปุ่มต่างๆ ของ VEX IQ (รุ่นที่ 2)
pressed— ลงทะเบียนฟังก์ชันที่จะถูกเรียกเมื่อกดปุ่มที่ระบุreleased— ลงทะเบียนฟังก์ชันที่จะถูกเรียกเมื่อปล่อยปุ่มที่ระบุ
ตัวรับข้อมูล — ส่งข้อมูลกลับจากปุ่มกดและแบตเตอรี่
pressing— ส่งคืนว่าปุ่มที่ระบุถูกกดอยู่หรือไม่capacity— คืนค่าความจุแบตเตอรี่ที่เหลืออยู่ของสมองvoltage— ส่งคืนแรงดันไฟฟ้าของแบตเตอรี่current— ส่งคืนกระแสไฟที่ดึงจากแบตเตอรี่
ตัวสร้าง — เริ่มต้นการทำงานของสมองด้วยตนเอง
brain— สร้างสมอง
การกระทำ#
pressed#
pressed ลงทะเบียนฟังก์ชันที่จะถูกเรียกเมื่อกดปุ่มเฉพาะบน Brain วิธีนี้ต้องถูกเรียกบนออบเจ็กต์ปุ่มเฉพาะ เช่น buttonCheck — (ดูรายการออบเจ็กต์ปุ่มทั้งหมดด้านล่าง)
วิธีใช้:
สามารถใช้ปุ่มหนึ่งในสามแบบที่มีอยู่กับวิธีการนี้ได้ ดังแสดงด้านล่าง:
ปุ่ม |
สั่งการ |
|---|---|
|
|
|
|
|
|
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
A function that is previously defined to execute when the specified button is being pressed. |
|
ตัวเลือกเสริม ทูเปิล ที่มีอาร์กิวเมนต์ที่จะส่งไปยังฟังก์ชันเรียกกลับ ดู ฟังก์ชันที่มีพารามิเตอร์ สำหรับข้อมูลเพิ่มเติม |
# Turn in a circle when the left button
# is pressed
def button_pressed():
drivetrain.turn_for(RIGHT, 360, DEGREES)
brain.buttonLeft.pressed(button_pressed)
released#
released ลงทะเบียนฟังก์ชันที่จะถูกเรียกเมื่อปล่อยปุ่มเฉพาะบน Brain วิธีนี้ต้องถูกเรียกบนออบเจ็กต์ปุ่มเฉพาะ เช่น buttonCheck — (ดูรายการออบเจ็กต์ปุ่มทั้งหมดด้านล่าง)
วิธีใช้:
สามารถใช้ปุ่มหนึ่งในสามแบบที่มีอยู่กับวิธีการนี้ได้ ดังแสดงด้านล่าง:
ปุ่ม |
สั่งการ |
|---|---|
|
|
|
|
|
|
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
A function that is previously defined to execute when the specified button is released. |
|
ตัวเลือกเสริม ทูเปิล ที่มีอาร์กิวเมนต์ที่จะส่งไปยังฟังก์ชันเรียกกลับ ดู ฟังก์ชันที่มีพารามิเตอร์ สำหรับข้อมูลเพิ่มเติม |
# Turn in a circle when the left button
# is released
def button_released():
drivetrain.turn_for(LEFT, 360, DEGREES)
brain.buttonLeft.released(button_released)
ผู้รับ#
pressing#
pressing จะส่งคืนค่าบูลีนที่ระบุว่าปุ่มใดปุ่มหนึ่งบน Brain กำลังถูกกดอยู่หรือไม่ ต้องเรียกใช้เมธอดนี้กับอ็อบเจ็กต์ปุ่มที่ระบุ เช่น buttonCheck (ดูรายการอ็อบเจ็กต์ปุ่มทั้งหมดด้านล่าง)
True— กำลังกดปุ่มที่ระบุอยู่False— ไม่ได้กดปุ่มที่ระบุ
วิธีใช้:
สามารถใช้ปุ่มหนึ่งในสามแบบที่มีอยู่กับวิธีการนี้ได้ ดังแสดงด้านล่าง:
ปุ่ม |
สั่งการ |
|---|---|
|
|
|
|
|
|
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Turn when the check button is pressed
while True:
if brain.buttonCheck.pressing():
drivetrain.turn(RIGHT)
else:
drivetrain.stop()
capacity#
capacity จะแสดงระดับแบตเตอรี่ที่เหลืออยู่เป็นเปอร์เซ็นต์ตั้งแต่ 0% ถึง 100%
Usage:
brain.battery.capacity()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Display the current battery capacity
brain.screen.print(brain.battery.capacity())
voltage#
Voltage is the electrical pressure supplied to the battery. voltage returns the voltage of the battery as a decimal (float), which can help you check whether the battery is charged enough for the robot to run reliably, ranging from 7.0 to 8.0 Volts.
Usage:
brain.battery.voltage(units)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ตัวเลือกเสริม หน่วยที่ใช้แสดงแรงดันไฟฟ้า: |
# Display the current voltage of the battery
brain.screen.print(brain.battery.voltage())
current#
Current is how much electrical flow the robot is using from the battery. current returns the current drawn from the battery in amps as a decimal (float), which can help you see how hard the robot is working or whether motors may be under extra load, ranging from 0.0 to 15.0 Amps.
Usage:
brain.battery.current()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Display the current of the battery
brain.screen.print(brain.battery.current())
ผู้สร้าง#
Brain#
Brain สร้างอ็อบเจ็กต์ของคลาส Brain
Usage:
brain = Brain()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
brain = Brain()
# Turn when the check button is pressed
while True:
if brain.buttonCheck.pressing():
drivetrain.turn(RIGHT)
else:
drivetrain.stop()