虽然已经有不少类似的东西,但是用microbit更容易。
材料
程序
- input.onButtonPressed(Button.A, () => {
- for (let i = 0; i < 4; i++) {
- music.playTone(Note.G, music.beat(BeatFraction.Whole))
- basic.showLeds(`
- . # # # .
- # . . . .
- # . # # .
- # . . # .
- . # # # .
- `)
- }
- })
- input.onButtonPressed(Button.B, () => {
- for (let i = 0; i < 4; i++) {
- music.playTone(Note.C, music.beat(BeatFraction.Whole))
- basic.showLeds(`
- . # # # .
- # . . . .
- # . . . .
- # . . . .
- . # # # .
- `)
- }
- })
- input.onButtonPressed(Button.AB, () => {
- for (let i = 0; i < 4; i++) {
- music.playTone(Note.E, music.beat(BeatFraction.Whole))
- basic.showLeds(`
- # # # # .
- # . . . .
- # # # . .
- # . . . .
- # # # # .
- `)
- }
- })
- input.onGesture(Gesture.Shake, () => {
- for (let i = 0; i < 4; i++) {
- music.playTone(Note.A, music.beat(BeatFraction.Whole))
- basic.showLeds(`
- . . # . .
- . # . # .
- # # # # #
- # . . . #
- # . . . #
- `)
- }
- })
复制代码
https://www.hackster.io/FrauHmpf/are-you-in-tune-895805
|