[Boson for micro:bit] Music Box 08
userhead
LiLy Nov 15.2021
projectImage
projectImage
projectImage
projectImage

STEP1: connect micro: bit board to computer with USB cable, plug the earphone in the expansion board; connect the motion sensor to pin P1 of the expansion board.

projectImage
projectImage

STEP2: Programming

1.     Drag “pin P0 play sound…until done” block from “micro: bit” module to script area. There are many built-in sounds to choose. We select the sound “dadadadum” here.

projectImage

2.     Run the program

projectImage
projectImage

1.    Program to generate a piece of music of Twinkle, Twinkle, Little Star.

projectImage
projectImage

2.     Drag “pin P0 play note-C2 for 1beat” from the “micro: bit” module to script area. Revise the parameter “C2” to play different notes, and change the parameter ”1” to adjust the beat.

projectImage

3.     Motion sensor has been connected to pin P1, if someone passes near the device, the value of P1 will be 1, otherwise, it will be 0. Therefore, combining it a “if then…else” statement, we can make the smart music box come to life.

projectImage
projectImage

Previous chapter: Automatic Door 07                                               Next chapter:Colorful LED Strip 09

 

Click to buy

License
1
All Rights
Reserved
[[i.text]]
licensBg
0
0
COMMENTS ([[commentTotla]])
[[c.user_name]] [[c.publish_time]]
[[c.parent_comment.count]]