# Case 07: Auto Lamps ## Introduction --- - The auto lamps are able to turn on when the night is approaching and to turn off while the daylight comes. ## Function --- - Detect the light level with the light sensor on micro:bit, if the light level is too low, program to turn on the lamps; or to turn off the lamps. ## Products Link --- - 1 x [microbit Smart City Kit](https://shop.elecfreaks.com/products/elecfreaks-micro-bit-smart-city-kit-without-micro-bit-board?_pos=1&_sid=ce30b50b6&_ss=r) ## Picture --- ![](./images/microbit-Smart-City-Kit-case-01-02.png) ## Hardware Connection --- Connect the yellow LED to P1 port on IoT:bit. ![](./images/microbit-Smart-City-Kit-case-07-03.png) ## Software Program --- Click "Advanced" in the MakeCode drawer to see more choices. ![](./images/microbit-Smart-City-Kit-case-01-04.png) For programming, we need to add a package: click "Extensions" at the bottom of the MakeCode drawer and search with "iot-environment-kit" in the dialogue box to download it. ![](./images/microbit-Smart-City-Kit-case-01-05.png) ***Notice:*** If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu. ## Program --- Detect if the light level is below 100. ![](./images/microbit-Smart-City-Kit-case-07-07.png) If yes, set to light on the LED; or light off it. ![](./images/microbit-Smart-City-Kit-case-07-08.png) Link: [https://makecode.microbit.org/_RJV5CuH4i1f9](https://makecode.microbit.org/_RJV5CuH4i1f9)
## Result --- - If the light level is too low, program to turn on the LED automatically; or to turn off it.