Lesson 13: Read the colours
이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Colours carry messages
- A colour on the floor can be a message for the robot: a parcel label, a road sign, a place to stop.
down_eye.detect(RED)isTruewhile the robot stands on red. It knows RED, GREEN, BLUE and BLACK.- The eye only sees the floor under the robot now. To use a colour later, keep it in a variable.
Words for this lesson
| Word | Meaning |
|---|---|
| label | a small sign on a parcel that says where it goes |
| bay | a marked place where a robot puts things down |
| variable | a name that remembers a value, like colour = "red" |
| sign | a picture or colour that tells you what to do |
| arrive | get to the place you wanted to go to |
English
Remember what you saw
from vexcode_vr import *
def main():
colour = "none"
if down_eye.detect(RED):
colour = "red"
drivetrain.drive_for(FORWARD, 500, MM)
brain.print("I started on: " + colour)
vr_thread(main)
colourgets its value at the start. After the drive the robot still knows it, even though the floor under it has changed.==asks "is it the same?":if colour == "red":isTrueonly whencolourholds"red".
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
The post robot stands on a parcel with a colour label: red, green or blue. Take the parcel to the bay of the same colour. Read the label first and keep it in a variable, because the eye cannot see it any more once the robot moves. Route: 1000 mm up; for red turn left, drive 600 mm, turn right; for blue do the same to the right; then 500 mm up into the bay.
출력을 보려면 '실행'을 클릭하세요.
난이도 3/5 · 200코인 + 오늘 첫 완료 시 작은 보너스 추가
Coloured signs on the floor show the way. Red means turn left, blue means turn right, green means stop: you have arrived. Drive one square (250 mm) at a time and look at the floor in every square. Each map has a different route.
출력을 보려면 '실행'을 클릭하세요.