This project belongs to the Kitronik :MOVE Motor series projects, it based on PJ009.2: Collect MOVE vehicle sensors data. The project uses the vehicle's onboard ultrasonic sensor to detect the front environment, so to avoid collision to obstacles. Goals:
Fun experience with Kitronik :MOVE Motor's onboard ultrasonic sensor
Engineering practice: Problem analysis, algorithm designing, solution implementation and tuning for a result
Practice with while-do looping logic
Practice using Functions to structure the program design
Inspire interests on robotics and programming
START A BIT > Projects Library > This page
Here is the demo of the planned results.
And a successful result by a student.
Just the standard TM015: Kitronik :MOVE Motor for Micro:bit kit, remember to install the 4 batteries, no extra need.
The vehicle will be placed in a random place on the floor in the room, and use the "logo" touching to start, then the vehicle should start moving forward, it should stop safely when detecting an obstacle in the front, then reverse a little, turn around a little, and continue exploring on the floor.
[x] Simple: 30-60 minutes
[ ] Moderate: 1-2 hours
[ ] Challenging: more than 2 hours
The estimation bases on average situation without unexpected difficult troubleshooting. It only indicates rough time needed to complete this project, but not about technical difficulty, not covering discussion and sharing time. Here is a possible breakdown:
5-8 minutes: Understand requirement and goals, collect materials
15-20 minutes: Programming, download to Micro:bit, test and improve program, retest to reach a good result
One should have prior knowledge
Micro:bit V2 board: Know what it is, better to have prior experience using them
MakeCode by Microsoft, the programming tool, better to have prior experience using it with Micro:bit
Not a must, but better to have completed PJ009.2: Collect MOVE vehicle sensors data
1x TM015: Kitronik :MOVE Motor for Micro:bit, unboxed, or assembled
4x Alkaline AAA batteries
1x Micro:bit V2 board , with USB cable
Click "Extensions"
Search by keyword "MOVE"
Click the found result
Then "MOVE Motor" blocks are available
Just use the block as a value of the measured distance, the unit , in cm or inch, needs to be set on start.
MOVE Motor -> Sensors-> Ultrasonic->
Remember to set unit on start
This makes the vehicle spinning around the "pen hole" in the middle of the vehicle chassis.
This is useful to help the vehicle finding another new direction to drive after detecting an obstacle in front.
MOVE Motor -> Motors-> Drive->
This while-do looping is useful to help the continuous checking the ultrasonic sensor value until finding the obstacles
Loops ->
It's smart to use a random value when exploring the new direction after meeting an obstacle.
E.g. Reverse to a random place, turn around to a random angle. This will make the vehicle finding a new way in a flexible result, avoiding dead lock in a corner in extreme case.
Math ->
It's interesting to make the vehicle sounding an alarm when doing the re-exploration to a new direction.
Note:
When turning on, it keeps alarming, need to turn off when it's done. This works much alike the reversing alarm in real vehicle.
MOVE Motor -> Sounds ->
This is the main logic, as reference. There could be other solutions and the logic flow could differ a bit.
Note:
The blue block "call ..." is calling the functions that are defined separately.
the threshold of 10 cm to detect obstacle is a temporary value, you need to fine-tune it for a good result in your actual situation
This is the fun part! The students should be flexible to explore their own strategy of exploring a new way.
Here is just an example "stop_and_explore_a_new_way" for reference. We use random amount to reverse, and turning for new direction, so to better explore a new way, avoiding dead lock in reality.
What happens if only keeping "spin" part in the "stop_and_explore_a_new_way" algorithm?
Do you have other algorithm/solution for the vehicle to explore a new way? The different strategy of exploring a new way could make big difference of the working result, try something out by yourself!
What will happen if there is no "pause (ms) (...)" after the while-do?
Share with your group about
What troubles you met
How you analyze
How you get help
How you solve it
What you have learnt
More document and tutorials in TM015: Kitronik :MOVE Motor for Micro:bit
The current solution makes the vehicle exploring all the time, never stop. Can you improve the program to let it stop after 10 times of obstacle detected?