6. case 04:Timer#

6.1. Our Goal#


  • Use our watch kit to create a wearable timer.

6.2. Material#


  • 1 x Watch kit

6.3. Hardware Connection#


Assemble our watch kit directly just like the picture below.

../../_images/vOZpBF4.jpg

6.4. Software#


Microsoft Makecode

6.5. Programming#


Step 1#

  • When start our program, create a variable flag and set its value to 0. When button A is pressed, delay time for 5 second. When button B is pressed, set the value of variable flag to 1.

../../_images/cP4zcvV.png

Step 2#

  • Create a forever loop and place an if statement under it. When the variable flag equals to 1, then activate the function.

  • Set time delay and play the built-in music nyan for once. Then set the variable flag to 0.

../../_images/lcr6uOP.png

Program#

6.6. Result#


  • The watch can keep time precisely and play music.

6.7. Think#


6.8. FAQ#


6.9. Relative Readings#