# Lab 4 - Exercise 1
## Question
* Identify the Boolean expression to implement the following requirement and implement the same using logic gates in Wokwi tool. Explain your solution.
* We need to design a logic for coffee / milk dispenser machine as follows.
1. We have the request to dispense Milk or Coffee from the user i.e User will press the button CREQ for Coffee, MREQ for Milk. (Note for both Coffee and Milk, we need milk to be available and also its hot)
2. Milk availability is known by a level sensor M. If M is high Milk is available else its not.
3. Similarly Milk is hot or not is known by temperature sensor T. If T is high milk is cold, if T is low, Milk is hot.
4. Coffee powder availability is known by sensor C. If C is high we have coffee powder else we don't have.
5. Coffee can be dispensed only when hot milk and coffee powder is available. Milk can be dispensed only when hot milk is available.
6. To dispense Coffee we need to generate a output Coff_Out as high (the output Coff_Out will be used in the system to open a electrically operated valve to dispense the coffee).
7. Similarly to dispense Milk, we need to generate an output Milk_Out high.
8. If Milk quantity or Coffee powder quantity is not available we need to generate an output Insuff_Qty as high.
## Solution
* Final Expressions after solving K-Maps implemented here using logic gates are:
* `Coff_Out(CREQ, MREQ, M, T, C) = CREQ.M.T'.C`
* `Milk_Out(CREQ, MREQ, M, T, C) = MREQ.M.T'`
* `Insuff_Qty(CREQ, MREQ, M, T, C) = MREQ.M' + CREQ.(M' + C')`
### Truth Table for expressions
| CREQ | MREQ | M | T | C | Coff_Out | Milk_Out | Insuff_Qty |
|------|------|---|---|---|----------|----------|------------|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 | 0 |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