Lesson 6 Growing Stage: Auto Weeder Control
Challenges: 6-1, 6-2
Students will express a program using a flowchart and use the flowchart to organize an algorithm to address the problem.
I can explain if-then-else conditionals in a program.
I can use if-then-else conditionals to control hardware.
I can use a flowchart to plan and organize my programming ideas.
Engage
2 min.
On a farm, when using a manual weeder, the grass is often cut unevenly, leaving a messy, uneven field.
What do you think is the key to getting a clean, even cut with a weeding machine? Guide students to think about distance.

What sensor could help us measure that distance?
Background
3 min.The ultrasonic sensor works like a bat's echolocation. It sends out a sound wave and listens for the echo to bounce back. By timing this, it can calculate distance.

The read the distance block returns the distance in centimeters.

The fan module represents the cutting blade of our auto weeder.

The fan's speed is controlled by Pulse Width Modulation (PWM) using the analog output block. The value ranges from 0 to 1023, with the default value of 512 representing medium speed.

Build and Connect
10 min.
![]() | Build together by following the Building Instruction. |
NOTE: Students can install the UNIHIKER K10 on the weeder using block pins.
Program
25 min.
Challenge 6-1: Predict and Test
![]() | Ask students to connect the ultrasonic sensor and the fan to the UNIHIKER K10. |
![]() | Ask students to predict what they think will happen. Encourage students to describe the process in the if/then frame. |
![]() | ![]() Ask students to upload the program. What data is the UNIHIKER K10 reading now?The numbers on the screen report the distance between the ultrasonic sensor and the ground (if the sensor faces the ground without any obstacle in the middle). Difference speed: PWM values control the fan speed. A higher value means faster rotation. |
Introduce the key vocabulary flowchart.
A flowchart uses shapes and arrows to clearly show how a program works step by step.
![]() | Terminator (Oval): Represents the start or end of a flowchart. Example: Start, End. |
![]() | Arrow (Connector): Shows the flow or direction of the process. |
![]() | Process (Rectangle): Indicates a process, operation, or action. Example: turn the light on. |
![]() | Decision (Diamond): Represents a decision point with multiple outcomes (Yes/No, True/False). Example: Is temperature > 30? |
Challenge 6-2: Plan with a Flowchart
![]() | ![]() Prompt students to fill in the flowchart to explain how the smart window works. Here is an example answer: |
![]() | Challenge students to draw a new flowchart for this new rule. A typical solution might start with “measure distance,” then have a judgement diamond: “Is distance > 10 AND < 12?” with “Yes” leading to “Turn Fan ON” and “No” leading to “Turn Fan OFF.” |
![]() | Guide students to upload the program and test it. |
Extra Practice
5 min.
Modify the comparator: change Program 6-2 using two if-else-else functions to achieve the same result?

Add a Safety Alert: Program the weeder to play a warning sound when it is outside the safe operating range (not between 10–12 cm), alerting the user to adjust the height.

Next Class: Lesson 7
Current Tutorial: Click Here






















