Lesson 9: Colour tiles
หน้านี้ต้องใช้เบราว์เซอร์ล่าสุด (รองรับ SharedArrayBuffer) กรุณาอัปเดต Chrome, Edge, Firefox หรือ Safari เป็นเวอร์ชันล่าสุด
English
Colours on the floor
- The down eye looks at the floor under the robot.
down_eye.detect(GREEN)isTrueon a green tile. - It knows RED, GREEN, BLUE and BLACK.
location.position(Y, MM)tells you where the robot is: how far up (Y) or right (X) from the middle.
Words for this lesson
| Word | Meaning |
|---|---|
| detect | find; detect(RED) is True on red |
| tile | a coloured square on the floor |
| count | a variable that goes up by 1 each time |
| position | where the robot is, in mm |
English
Stop on a colour
from vexcode_vr import *
def main():
drivetrain.drive(FORWARD)
while not down_eye.detect(GREEN):
wait(5, MSEC)
drivetrain.stop()
brain.print("green!")
vr_thread(main)
- With no green tile on the floor the robot drives to the wall. On a task map it stops on the green tile.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Drive forward and stop on the green tile. The tile is in a different place on each map.
คลิก Run เพื่อดูผลลัพธ์ที่นี่
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Drive up the playground until Y is 700 mm or more. Count the red tiles the robot drives over, then print the number with brain.print(count).
คลิก Run เพื่อดูผลลัพธ์ที่นี่