# Case16: The Dazzling Lights ## Purpose --- - Simulate the lights of the police car. ## Material --- - 1 x [TPBot](https://shop.elecfreaks.com/products/elecfreaks-micro-bit-tpbot-car-kit-without-micro-bit-board?_pos=1&_sid=f32828112&_ss=r) ![](./images/TPBot_tianpeng_case_01_01.png) ## Hardware connection --- Connect rainbow led to port 1 on TPBot. ![](./images/TPBot_tianpeng_case_16_03.png) ## Software --- [MicroSoftmakecode](https://makecode.microbit.org/#) ## Programming --- Click "Advanced" to see more choices in the MakeCode drawer. ![](./images/TPBot_tianpeng_case_01_02.png) - We need to add a package for programming. Click "Extensions" in the bottom of the drawer and search with "tpbot" in the dialogue box to download it. ![](./images/TPBot_tianpeng_case_01_03.png) - We need to add a package for programming. Click "Extensions" in the bottom of the drawer and seach with "PlanetX" in the dialogue box to download it. ![](./images/TPBot_tianpeng_case_15_03.png) ### Sample - In on start brick, initialize the led strip and has it connected to J1 port, set TPBot move forward at the speed of 50%. - Save the variable "i" as 1 while pressing button A and set it as 0 while pressing button B. - In forever brick, judge if the variable "i" is 1, if yes, set the led in red and pasue for 500ms, after in blue and pause another 500ms; or set it in black. ![](./images/TPBot_tianpeng_case_16_04.png) ### Link - Linkļ¼š[https://makecode.microbit.org/_TvrRaMJLKPWr](https://makecode.microbit.org/_TvrRaMJLKPWr) - You may also download it directly below:
### Conclusion - The TPBot moves forward after powering on, press button A on the micro:bit to turn on the LED cycling with red and blue, press button B to turn it off. ## Exploration --- ## FAQ --- Q: While operating this case, why the car might not work properly? A: It might be the low power of the batteries, please try adding the value of TPBot's speed and test again. ## Relevant File ---