# Case 01: Automated Smart Playground Lamp Level: ![level](images/level1.png) ![auto_fit](images/Case1/case-01_1.png)

## Goal


Make a smart playground lamp by detecting the motion nearby.

## Background


What is smart playground lamp?

Smart playground lamp is a lamp which can open automatically when someone passes by. Installing an auto-light can help the earth save electricity. When no one passes by, the light will automatically turn off.

Smart playground lamp operation

Motion sensor should be able to detect if there are people moving in the playground.
If there are people moving in the playground, the LED light should turn on, vice versa.
![pic_60](images/Case1/Concept-diagram-Case1.png)

## Part List


![auto_fit](images/Case1/Case1_parts.png)

## Assembly step


Step 1

Attach motion sensor and white LED to A1 model with M4 * 10mm screws and nuts.

![auto_fit](images/Case1/Case1_ass1.png)

Step 2

Assembly completed!

![pic_40](images/Case1/Case1_ass2.png)

## Hardware connect


Connect Motion sensor to the P0 port of Smarthon IoT:bit

Connect LED light to the P3 port of Smarthon IoT:bit


![auto_fit](images/Case1/Case1_hardware.png)

*Pull the buzzer switch 'up' to disconnect the buzzer in this execrise* ## Programming (MakeCode)


Step 1. Disable micro:bit LED.

* Snap `led enable false` to `on start` * Note that P3 is used as LED in default setting, LED need to be disable ![auto_fit](images/Case1/Case1_p1.png)

Step 2. Turn on LED by motion sensor

* Drag `forever` from `Basic` * Snap `if statement` into `forever` * Set `get motion (triggered or not) at P0 = true`, into `if statement` that’s say motion is triggered, someone passes by. * Then, `turn white LED to 1023 at P3` as turning on white LED and pause 10 seconds. * Else, `turn white LED at P3 to 0` as turning off. ![pic_90](images/Case1/Case1_p2.png)

Full Solution

MakeCode: https://makecode.microbit.org/S68864-53853-05528-25643 ![pic_100](images/Case1/Case1_full_program.png)

## Result


Motion sensor is used to detect if there are people moving in the playground. If there are, the LED light will be turned on; otherwise, it will be turned off.

![auto_fit](images/Case1/Case1_result.gif)

## Think


Q1. How can you use motion sensors, other than turning on the light automatically?

Q2. Can you show motion sensor value on OLED?