Connect servo motor with OSOYOO PnP board for micro:bit P0 with OSOYOO 3-pin PnP cable ;

Connect button module with OSOYOO PnP board for micro:bit P1 with OSOYOO 3-pin PnP cable as below;

Step 0: Go to urlhttps://makecode.microbit.org, click New Project  

Step 1. In the Toolbox, click on the Logic category and then click the if-then-else block and place it inside the forever block .

Step 2. Drag and drop a 0=0 block inside the if-then-else block, and place it on the placeholder of the if-then-else block . Then set 0= 1 in it  as below figure.

Step 3. In the Toolbox, click on the Pins category under Advanced. Now, drag the digital read pin P0 block   and place it inside the placeholder of the 0=0 block. Then set read pin to P0 from the drop-down menu as below figure.

Step 4. Drag and drop a servo write pin block ,place it inside the “then” section of the if-then-else block. , set value to  100 from the drop-down menu as below figure.

Step 5. Click on the Basic category ,  drag the show leds block  and place it inside   the then block just below the servo write pin to block. Then draw a “square” by clicking the dots in the 5×5 matrix as below figure.

Step 6. Drag a pause(ms) block from Basic category over and place it inside the then block just below the show leds block , and set the pause time(ms) to 1000 as below figure.

Step 7. In the Toolbox, click on the Pins category,  drag the servo write to block and place it inside the else block. and set write pin value to  0 from the drop-down menu as below figure.

Step 8.  Click on the Basic category again , drag the show leds block place it inside  the else block just below the servo write pin block. Then draw a “X” by clicking the dots in the 5×5 matrix as below figure.

Step 9.Download this “.hex” file and save it to your MICROBIT disk Driver as following figure.

Below are the full Graphic programming code blocks  we have done for you as reference: