انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Maker: home
0. Lab tour1
1. The start: the Arduino6
2. Wiring and the traffic light4
3. Inputs: the button4
4. Sound and movement5
5. Sensors and numbers5
6. Distance, the screen and colours5
7. Motors and the car4
8. The project: the city's smart gate3
9. From blocks to C++ code5
10. Sensors and screens in code5
11. Smart systems5
12. Bluetooth: control from the phone1

Avoiding obstacles

Section 7: Motors and the carLesson 7.3 · ⏱ 10 min

We put the distance sensor on the front of the car: if an obstacle comes close, it backs up a little and turns, otherwise it moves forward. Now we have a smart robot that decides by itself.

🧩 Avoiding obstacles
Blocks: loop — repeats forever

📌 Another example: it stops before the wall

If the wall is closer than 20 cm it stops, otherwise it moves.

🧩 It stops before the wall
Blocks: loop — repeats forever
Far: it moves
Far: it moves
Close: it stops
Close: it stops
✍️ Practise
Stop before the wall.
✍️ Practise here in the lessonor open the lab in a new page ↗
✍️ Practise
Avoiding obstacles.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

Close: it backs up.

👀 Show the solution
🧩 Solution
Blocks: loop — repeats forever
In the lab
In the lab

Result: it backs up.

Medium

Close: it turns to avoid the wall.

👀 Show the solution
🧩 Solution
Blocks: loop — repeats forever
In the lab
In the lab

Result: it turns.

Hard

It slows down: between 20 and 50 cm speed 100, closer than 20 it stops, and farther speed 200.

👀 Show the solution
🧩 Solution
Blocks: loop — repeats forever
In the lab
In the lab

Result: it moves slowly near the wall.

Finished the lesson? Mark it so your progress counts.