This project uses a single Micro:bit to implement several versions of Baby Faces, this is part of the starting experience of Micro:bit and basic programming logic of if-else and usage of Variable . Junior learners should take Task 1-2, challenge takers should try Task 3 further. Goals:
Fun playing with Micro:bit with microphone to catch sound events and original sound levels
Practice of basic if-else logic
Basic usage of Variable (numeric integer type)
Understand the tricks of Event-Triggered blocks
START A BIT > Projects Library > This page
This is a demo for Task 1
[x] Simple: 30-60 minutes
[ ] Moderate: 1-2 hours
[ ] Challenging: more than 2 hours
The estimation bases on average situation without unexpected troubleshooting, assuming that the student meets prerequisites. It only indicates rough time needed to complete this project, but not about technical difficulty, not covering discussion and sharing time. Possible breakdown:
Task 1: 20 minutes
Task 2: 30 minutes
This is just like a Baby, with a quickly changing Face, i.e. SMILING in normal situation, becomes CRYING if scared by a LOUD sound, but will return as SMILING after a while.
Micro:bit shows SMILING face after starting
When a LOUD sound happens, it becomes CRYING (or SAD) face, and keep this for 5 seconds
If there is continuous LOUD sound happening, it should keep CRYING, as soon as the LOUD sound stops, it should keep CRYING for 5 seconds
Then, it becomes SMILING face again, and stay SMILING as long as no LOUD sound
Before starting, please study this very helpful prerequisite knowledge KB034: Microphone in Micro:bit! Depending on your design and solution, you might need some of those kind of blocks, not all are suitable or useful, just for your reference.
Purpose: Try a straightforward version that most students will do
Test with Simulator in MakeCode, and Test with Target Micro:bit.
Test Case 1:
After starting up, Micro:bit shows SMILING face, then make 1 loud "Boom", it becomes CRYING face, and stay for 5 seconds, then becomes SMILING again, and keep SMILING stably.
Test Case 2:
After starting up, Micro:bit shows SMILING face, then make 3 continuous loud "Booms", it becomes CRYING face on the first "Boom", and stay CRYING during the following "Booms", then after the last "Boom", it stays CRYING for 5 seconds, then becomes SMILING again, and keep SMILING stably.
Please submit your work to Google Classroom (here is a guide)
Add comments to the assignment for your test results according the Test Cases 1-2
These examples are from the students, they are not necessarily in right results, but for your reference... Do you think alike?
There are different solutions, the final result could be felt a little different, please try and find out what and why.
Here is a tip of the tricky algorithm, be careful with the execution orders of multiple independent Housing-blocks.
Here is the tips of loud/quiet sound level, for your reference.
Make your own version, test with careful Test Cases
Some of the examples will fail Test Case 1 and Test Case 2, because of the conflict parallel accessing the same Micro:bit LED screen from "on loud sound" and "on quiet sound".
Some of the examples will pass Test Case 1, but fail Test Case 2, because the "on loud sound" is an Event-Triggered block that will buffer and queue the burst "Booms", so it triggers multiple "on loud sound" events, so Test Case 2 will see unexpected more than 1 time of CRYING.
We can visualize the bug in the simulator.
Purpose: Try out different ideas, and affects of the results
Test with Simulator in MakeCode, and Test with Target Micro:bit.
Test Case 1:
After starting up, Micro:bit shows SMILING face, then make 1 loud "Boom", it becomes CRYING face, and stay for 5 seconds, then becomes SMILING again, and keep SMILING stably.
Test Case 2:
After starting up, Micro:bit shows SMILING face, then make 3 continuous loud "Booms", it becomes CRYING face on the first "Boom", and stay CRYING during the following "Booms", then after the last "Boom", it stays CRYING for 5 seconds, then becomes SMILING again, and keep SMILING stably.
Please submit your work to Google Classroom (here is a guide)
Add comments to the assignment for your test results according the Test Cases 1-2
This is an example, try to read and understand the logic
Make your own work based on this example, you can change/add blocks to fit your needs. Test the result using the Test Cases
This version will pass Test Case 1, and is more satisfying in Test Case 2 comparing to Task 1's version.
But still fails Test Case 2 when the loud sound persists above 169, then we will observe that it keeps CRYING for 5 seconds, then suddenly pops a SMILING, then continues CRYING for another 5 seconds, then suddenly pops a SMILING... and this loops. The sudden SMILING is not expected because the loud sound is still happening, the baby should just keep CRYING without any SMILING as long as the loud sound keeps.
We can visualize this bug in the simulator.
Purpose: Creative task for your ideas, as an optional challenge task
Task 2's example has a small bug when the loud sound persists above 169, then we expect that the baby keeps CRYING all the time as long as the loud sound keeps, but the result will have unexpected short SMILING popup in every 5 seconds. Can you fix this?
Purpose: Enhance basic knowledge understanding, reflect and summarize what we have learnt
How do we get sound level input? What is the value of it in the programming?
What is the difference between our self-made "if sound_level > 169" and the "on loud sound" solution?
Tips: Review knowledge from here if needed
Follow the tutor to take 5-10 minutes to review the questions and answers, correct some possible misunderstood issues or faults
Take 1-2 minutes to explore anything on the tools and the making flow, with curiosity, no matter how much prior knowledge you have, you should make
At least 1 interesting finding
At least 1 curious question