Lesson 36: Radar
このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
English
Look all around
- One distance sensor sees only what is straight in front of it.
- Put it on a servo, and it can turn and look in every direction. This is how a simple radar works.
- The radar turns step by step, measures at each angle, and remembers where the nearest object is.
Words for this lesson
| Word | Meaning |
|---|---|
| radar | a machine that finds objects around it |
| scan | look at every direction, one after the other |
| nearest | the one with the smallest distance |
| angle | the direction, in degrees (°) |
English
Collect, decide, act
| Step | In your code |
|---|---|
| collect data | at each angle: turn, wait, readCm() |
| decide | keep the smallest distance and its angle |
| act | turn back to nearestAngle and beep |
- On the board, watch the servo turn and the distance change when it points at an object.
English
In the exam
- 0478/12/O/N/24 Q8(a): a robot vacuum cleaner uses sensors to move around obstacles in a room. Which sensor is the most suitable? A proximity sensor, like your distance sensor.
- Q8(c) of the same paper: explain how the robot vacuum cleaner could use machine learning. It collects data while it cleans, for example where the obstacles are, and changes its own route next time. Your radar collects the data; a learning robot would keep it and use it again.
難易度 4/5 · 280 コイン + 今日初回達成時の小ボーナス
The distance sensor sits on a servo (pin 6), so it can look in every direction, like a radar. Turn the servo from 0° to 180° in steps of 10°. At each angle wait 150 ms, measure with readCm() and print the angle and the distance, like 60: 39. Keep the smallest distance and its angle, and at the end print Nearest at and that angle.
実行ボタンをクリックして出力を確認してください。
難易度 5/5 · 400 コイン + 今日初回達成時の小ボーナス
Now the radar guards a door. After the scan, turn the servo back to the nearest object and keep it pointing there. If that object is closer than 50 cm, give one warning beep with tone(8, 1500, 500). The objects are in other places now.
実行ボタンをクリックして出力を確認してください。