This project uses the Micro:bit's built-in light sensor to detect the environmental brightness, it sounds an alarm when the "day" gets bright enough from a dark starting, simulating a normal alarm clock, but without any tick-tock timing, programmed by MakeCode blocks. This project looks easy, but requires solid solution to achieve a reliable result, without non-stopping alarming, or unnecessary alarm when the "day" turning from bright to dark. Goals:
Consolidate knowledge: Input-process-output basic concept
Consolidate knowledge: Variable basic concept and if-else logic
Fun experience with Micro:bit built-in sensors and buzzer
START A BIT > Projects Library > This page
For your reference, here are some solution or creative result by our students, please mind that the demo there is not exactly in the required logic here.
Demo of the basic function (Task 2)
Demo of the challenging task with calibration mode
An example buggy result of repeating alarming
[ ] Simple: 30-60 minutes
[x] 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. Here is a possible breakdown:
5 minutes: Understand requirement and solution, collect materials
10-15 minutes: Programming prototype, test and find out improvement points
20-30 minutes: Programming refinement, refactor and retest
One should have prior knowledge
MakeCode by Microsoft, the programming tool
The light level is analog signal, and converted to a ranged integer result:
0 (darkness) ~ 255 (brightest)
Purpose: Get brightness input, use it to trigger an action when it reaches a specific level
Trigger alarm when the brightness reaches 128
The alarm should ring only 1 time, but not repeating/non-stop alarming
Test with simulator in MakeCode and real target Micro:bit.
Test Case 1:
Slowly changing from dark to bright, somewhere in the middle point, the alarm rings, but only for once, should NOT repeat ringing.
Test Case 2:
Slowly changing from bright to dark, somewhere in the middle point, the alarm rings, but only for once, but repeating ringing.
Please submit your work to Google Classroom (here is a guide)
Below are some examples by our students, not exactly working as expected, but for your reference, please fix any faults or bugs to make it working right
Purpose: Use variable and if-else to reach an expected logic
Trigger alarm when the brightness reaches 128
The alarm should ring only 1 time, but not repeating/non-stop alarming
The alarm should only ring for dark->bright changing direction, but not the opposite way
Test with simulator in MakeCode and real target Micro:bit.
Test Case 1:
Slowly changing from dark to bright, somewhere in the middle point, the alarm rings, but only for once, should NOT repeat ringing.
Test Case 2:
Slowly changing from bright to dark, the alarm should never ring.
Please submit your work to Google Classroom (here is a guide)
Why pause 1000ms? What if not pausing?
Test to see how reliable it is
When light level becomes from dark to light slowly, what happened when light level = 128?
What happens next?
Why setting last_light_level to "light level" on start?
Test to see how reliable it is
When light level becomes from dark to light slowly, what happened when light level = 128?
What happens next?
Purpose: Use variable and if-else to reach an expected logic
It's possible to calibrate an expected brightness level when starting up Micro:bit, please think about a solution and try out your ideas.
What we want in more details:
When Micro:bit starts up, give some hint to the user to give light input, i.e. entering a calibration mode
The user puts Micro:bit to an environment where the brightness level is as expected to be the alarming point
Micro:bit accepts the input light level, gives a hint to the user, now it's normal operation mode
Purpose: Enhance basic knowledge understanding, reflect and summarize what we have learnt
Share the work result with your classmates, friends or family
Tell what it is your product
Demonstrate how it works
Explain how it works
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
Use your own way to visualize how the programming controlling logic is done, by a free style drawing, so that your friends can follow this flow-chart to reproduce the programming.
You might be interested to know what is "flow chart", click to learn more, but so far, it's not needed to be that serious, just draw something that can help you explain to your friends how the programming is made.