# Case 05: Smart Fridge Alert Level:  
## Goal
## Background
Smart Fridge is a Fridge that has an extra sensor to help it determine the door close state, when the user forgets to close the door, it will warn the user to close it to reduce waste of energy and prevent food poisoning.
Smart Fridge Alert Principle
Firstly, we set the time counter variable as 0. When the door is closed, inside the fridge should be dark (light sensor value < 30), nothing happened;
When the door is opened, the room light will go into the fridge (light sensor value > 30), the counter will start counting the time every 1 second, if time counter > 60, the buzzer will be turned on to alert the user.

## Part List
## Assembly step
In this case, “Big House Model” is used as a home base to start with.

Step 2
Let’s build a kitchen. Put Model E3 onto the Model A and B4, align with the holes at it. Put Model E1 onto the Model A, align with the holes at Model A and B3.

Step 3
Completed.

Step 4
To build a fridge, attach light sensor onto model G1 using M4 * 10mm screws and nuts. And the connecting wire could be bended to the hole below it.

Step 5
Fold and bend the Model G1 accordinglyand put Model G3 into the Model G1, align with the holes.

Step 6
Put Model G2 onto the Model G1, align with the holes.

Step 7
The fridge completed!

Step 8
Place the fridge at the corner.

Step 9
Assembly Completed! 
## Hardware connect
## Programming (MakeCode)
* On start, create a “counter” variable and set to 0 

Step 2. Examine the light intensity
* In `Forever`, put a `if-else` statement * Use `Get light value (percentage) at Pin P1 > 30` as condition 
Step 3. Warning counter
* In the `if` segment, that's means the light intensity is strong, the door was opened * Add the counter with 1 by `change counter by 1` to sum up the time of door opened * Put the second `if` statement with `counter >= 60` condition to examine when should issue warning sound * In the sencond `if` segment, put `start melody jump down repeating once` to issue the warning sound * Back to the first `if-else` level, in the `else` segment, that's means light intensity is weak, door was closed, so reset the counter to 0 by `set counter to 0` * Put a `pause (ms) 1000` to check the door each second 
Full Solution
MakeCode: [https://makecode.microbit.org/S58749-50803-30551-09828](https://makecode.microbit.org/S58749-50803-30551-09828)
You could also download the program from the following website:

## Think
## Results
When the door is opened for more than 1 minute, the buzzer will play some sound to warn the user.
1. Apart from making the sound from the buzzer, another method to warn the user?
2. Can you make use of the fridge, to make a smart box to alert users?