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 Boolean type
Fun experience with Micro:bit built-in sensors and buzzer
Try a "Test Driven" programming practice
Software: Boolean type variable, if-else logic
START A BIT > Projects Library > This page
Here is an example of the successful result.
Basically, we only need the Micro:bit single board, with the USB cable, nothing more.
We shed a table light toward the Micro:bit board, which is fully covered by hands (or other helper materials) to simulate a very dark environment
Micro:bit should be quiet, nothing special happens
We open the covering slowly, to simulate the day getting brighter and brighter, when it reaches a "brightness" level that you define as right time to get up from the bed
Micro:bit plays an alarm sound for 1 time, after this, it keeps quiet even the environmental light gets brighter till we fully open the hands
Then, we slowly cover back, to simulate the day becoming darker and darker, until we fully cover the Micro:bit board again
During this darkening-process, the Micro:bit board should always keep quiet, nothing should happen
Then again, we gradually open the hands, until it gets bright enough, then the Micro:bit sounds the alarm again for another new day!
We should be able to repeat the above day-brighting and day-darking process with the reliable result
[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. Here is a possible breakdown:
5 minutes: Understand requirement and solution, collect materials
10-15 minutes: Programming prototype, test and find out improvement points
15-20 minutes: Programming refinement, refactor and retest
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
1x Micro:bit V2 board , with USB cable
Let's make a simple prototype first! This step is as simple as you can imagine, just do it and test on Micro:bit board.
To get the environmental brightness, you use this "light level" block, it is actually a variable, it has values between 0 (darkest) to 255 (brightest).
Input ->
To judge if the brightness is enough to do something, you need these logical blocks.
Logic -> Conditionals ->
Logic -> Comparison->
To play a sound, use this, it is not the only solution, you can also try other sound related blocks
Music -> Tone ->
You also need both or either blocks to help making things work. They are normally prepared, just use it when needed.
Basic ->
Basic ->
Usually, by this tip so far and active exploration, you can get it done! Please try really hard, before getting super tips if you are stuck.
This optional part covers further competence development, in terms of testing, troubleshooting, analysis, documentation, flow chart diagrams practices, etc.
Stand in front of the class, share with your group what you have made, please cover important points
Tell what it is your product
Demonstrate how it works
Explain how it works
Share with your group about
What troubles you met
How you analyze
How you get help
How you solve it
What you have learnt
Use your own way to visualize how the hardware components are connected by a free style drawing.
Visualize clearly the wiring path, mark clearly the pins and end points
So that your friends can follow this drawing to correctly reproduce the hardware setup
Any kind of children style drawing is OK! Here are some examples.
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.
Tell us what is variable and what is boolean type variable in your own way, explain how this variable helps you in this project.
What if you forget "on start" setting to initialize the variable?
What if you forget to update the "is_led_on" Boolean variable (flip to its opposite side) after turning on/off the LED?
These questions are out of scope for this project, but great to think about them, ask and discuss if you have enough effort
Logical "not" operation on Boolean type variable to flip its value, if this is difficult for you to understand, then park it here, not a mandatory point for now.
How to read the resistor value by the color rings?
If using external button and "read digital pin..." method to do the similar task to alternately turn on/off external LED, then we will meet the classic press-button bouncy problem... if you have questions on this, it's not a must to understand for now...
If you get a quick done, do you dare to take further challenges? Those challenging points are independent, not related to one another
(This project doesn't really have a further challenge yet)