# case 21 An Oscillating Fan ## Introduction Combine the motor and the servo to make a common head-shaking fan in daily life, and control the fan head-shaking function and turn it on and off by pressing the button. ![](./images/case_21_01.png) ## Quick Start ### Materials Required Nezha expansion board × 1 micro:bit × 1 360°servo × 1 Motor × 1 Bricks × n ***Tips: You may need to purchase [Nezha Inventor's Kit](https://shop.elecfreaks.com/products/elecfreaks-micro-bit-nezha-48-in-1-inventors-kit-without-micro-bit-board?_pos=2&_sid=ed1b6fbd2&_ss=r) if you want all the above compoents.*** ### Connection Diagram Connect the servo to S1, motor to M1 and the micro:bit to Nezha expansion board. ![](./images/case_21_03.png) ### Assembly Video Video:[https://youtu.be/Ysg-t4QNmo8](https://youtu.be/Ysg-t4QNmo8) ### Assembly Video ![](./images/case_step_21_01.png) ![](./images/case_step_21_02.png) ![](./images/case_step_21_03.png) ![](./images/case_step_21_04.png) ![](./images/case_step_21_05.png) ![](./images/case_step_21_06.png) ![](./images/case_step_21_07.png) ![](./images/case_step_21_08.png) ![](./images/case_step_21_09.png) ![](./images/case_step_21_10.png) ![](./images/case_step_21_11.png) ![](./images/case_step_21_12.png) ![](./images/case_step_21_13.png) ![](./images/case_step_21_14.png) ## MakeCode Programming ### Step 1 Click “Advanced” in the MakeCode drawer to see more choices. ![](./images/case_01_10.png) We need to add a package for programming. Click “Extensions” in the bottom of the drawer and search with “nezha” in the dialogue box to download it. ![](./images/case_03_09.png) ***Note:*** If you met a tip indicating that the codebase will be deleted due to incompatibility, you may continue as the tips say or build a new project in the menu. ### Programme as the picture shows: ![](./images/case_21_17.png) ### Link Link:[https://makecode.microbit.org/_hWzUHCY0yioM](https://makecode.microbit.org/_hWzUHCY0yioM) You may also downoad it directly below:
### Result Turn on/off the fan by pressing button A/B. ![](./images/case-gif-21.gif)