# Case 03: Garbage disposal system Level: ![level](images/level2.png) ![auto_fit](images/Case3/case-03.png)

## Goal


Make a smart garbage bin by showing different colors of light according to the volume of garbage inside.

## Background


What is garbage disposal system?

LED light on the garbage bin can show people the amount of garbage inside the garbage bin so that garbage truck can easily determine if the garbage is full or not. This can minimize the wastage of the garbage bags and become a more environmental-friendly city.

Garbage disposal system operation

The distance sensor should be able to sense the amount of garbage is inside the garbage bin. Multi-colour LED can be used to emit different colour of light (green and red light), which represent the emptiness of the garbage bin.

![pic_70](images/Case3/Concept-diagram-Case3.png)

## Part List


![pic](images/Case3/Case3_parts.png)

## Assembly step


Step1

Attach the Multi-colour LED to C1 model with M4 * 10mm screws and nuts.

![pic](images/Case3/Case3_ass1.png)

Step 2

Attach the distance sensor to C2 model with M4 * 10mm screw and nuts.

![pic](images/Case3/Case3_ass2.png)

Step 3

Put together all the cardboard parts (C1-C2).

![pic_60](images/Case3/Case3_ass3.png)

Step 4

Assembly completed!

![pic_60](images/Case3/Case3_ass4.png)

## Hardware connect


Connect the Distance Sensor to P14 (trig)/ P15 (echo) port of IoT:bit

Connect Multi-color LED to P1 port of IoT:bit

![pic](images/Case3/Case3_hardware.png)

## Programming (MakeCode)


Step 1. Set variable and initialize multi-colour LED

* Inside `on start`, snap `set variable distance to 0` from `variables` * Snap `set strip to NeoPixel at pin... ` from `Neopixel`. Set pin P1 with 1 led of the block. * Snap `strip set brightness` from `Neopixel` > `more` and set brightness 50 * Snap `pause` to wait 5 seconds ![auto_fit](images/Case3/Case3_p1.png)

Step 2. Get distance value

* Inside block `forever`. Set `distance` to `get distance unit cm trig P14 echo P15`, that’s say get the distance value by connecting the distance sensor to P14 and P15 * Snap `if statement` into `forever`, set `distance ≤ 4` into `if statement` * Snap `Pause` to the loop to wait 1 second for next checking ![pic_90](images/Case3/Case3_p2.png)

Step 3. Show indicating colours with distance value

* If distance ≤ 4, then `strip show color red`, else `strip show color green` ![pic_90](images/Case3/Case3_p3.png)

Full Solution

MakeCode: https://makecode.microbit.org/S69465-27557-58756-99835 ![pic_90](images/Case3/Case3_full_program.png)

## Result


The distance sensor can return the distance value between the top of the garbage bin and the level of garbage inside the garbage bin. The LED light is used to indicate if the bin is full or not. If it is empty or there are some garbage, the LED turns green, if it is full, the LED turns red.

![pic](images/Case3/Case3_result.gif)

## Think


Q1. How to make sound notification if there are full of garbage (i.e. using buzzer)?