主要材料:樹藝、micro:bit、語音辨識IC
MakeCode程式碼:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | def on_asr_vocabulary_list_learning_entry_7(): strip.show_rainbow(1, 360) radio.send_number(16) basic.show_string("Craft") asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_7, on_asr_vocabulary_list_learning_entry_7) def on_asr_vocabulary_list_learning_entry_6(): strip.show_rainbow(1, 360) radio.send_number(17) basic.show_string("NFU") asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_6, on_asr_vocabulary_list_learning_entry_6) def on_button_pressed_a(): asr.set_asr_learn() basic.show_leds(""" # . . . . # . . . . # . . . . # . . . . # # # # . """) input.on_button_pressed(Button.A, on_button_pressed_a) def on_asr_vocabulary_list_learning_entry_8(): strip.show_rainbow(1, 360) radio.send_number(19) basic.show_string("Smart") asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_8, on_asr_vocabulary_list_learning_entry_8) def on_asr_vocabulary_list_learning_entry_10(): strip.show_rainbow(1, 360) radio.send_number(20) basic.show_string("Tree Art") asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_10, on_asr_vocabulary_list_learning_entry_10) def on_asr_vocabulary_list_learning_entry_4(): basic.show_leds(""" # # . # # # # . # # # . # . # # . . . # . # # # . """) strip.show_color(neopixel.colors(NeoPixelColors.PURPLE)) strip.show() asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_4, on_asr_vocabulary_list_learning_entry_4) def on_button_pressed_b(): asr.del_asr_learn() basic.show_leds(""" . # # # . # . . . . # . . . . # . . . . . # # # . """) input.on_button_pressed(Button.B, on_button_pressed_b) def on_asr_vocabulary_list_learning_entry_5(): basic.show_leds(""" # . . . # # . # . # # . # . # # . . . # . # # # . """) strip.show_color(neopixel.colors(NeoPixelColors.GREEN)) strip.show() asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_5, on_asr_vocabulary_list_learning_entry_5) def on_asr_vocabulary_list_learning_entry_9(): strip.show_rainbow(1, 360) radio.send_number(18) basic.show_string("STEAM") asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_9, on_asr_vocabulary_list_learning_entry_9) def on_asr_vocabulary_list_learning_entry_2(): basic.show_leds(""" . # # # . # . . . # # . . . # # . . . # . # # # . """) strip.show_color(neopixel.colors(NeoPixelColors.BLACK)) strip.show() asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_2, on_asr_vocabulary_list_learning_entry_2) def on_asr_vocabulary_list_learning_entry_3(): basic.show_leds(""" . # # # . # # # # # # # # # # # # # # # . # # # . """) strip.show_color(neopixel.colors(NeoPixelColors.RED)) strip.show() asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_3, on_asr_vocabulary_list_learning_entry_3) def on_asr_vocabulary_list_hi_shaun(): basic.show_icon(IconNames.HEART) radio.send_number(0) asr.on_asr(asr.vocabularyList.HI_SHAUN, on_asr_vocabulary_list_hi_shaun) def on_asr_vocabulary_list_learning_entry_1(): basic.show_leds(""" . # . # . # . # . # . # . # . # . # . # . # . # . """) strip.show_rainbow(1, 360) radio.send_number(1) asr.on_asr(asr.vocabularyList.LEARNING_ENTRY_1, on_asr_vocabulary_list_learning_entry_1) strip: neopixel.Strip = None basic.show_icon(IconNames.HAPPY) strip = neopixel.create(DigitalPin.P0, 32, NeoPixelMode.RGB) strip.show_rainbow(1, 360) radio.set_group(49) def on_forever(): strip.rotate(1) strip.show() basic.pause(sonar.ping(DigitalPin.P1, DigitalPin.P2, PingUnit.CENTIMETERS) * 10) basic.forever(on_forever) |
沒有留言:
張貼留言