-
Notifications
You must be signed in to change notification settings - Fork 1
kimura
Akimasa KIMURA edited this page Feb 25, 2018
·
7 revisions
- Google AIY Voice Kitを紹介した 👍
- ScratchDayでやりたいことを考えよう
ボタンとLEDの制御
呼び出し側でイベントのループを作り忘れないこと
from __future__ import print_function
import aiy.voicehat as voicehat
def _on_button_pressed():
print("Pushed")
button = voicehat.get_button()
if __name__ == "__main__":
button.on_press(_on_button_pressed)
while True:
pass- led.set_state(voicehat.LED.PULSE_QUICK) かっこいい点滅 🤓
- led.set_state(voicehat.LED.BLINK) 点滅
- led.set_state(voicehat.LED.OFF) オフにする
from __future__ import print_function
from time import sleep
import aiy.voicehat as voicehat
led = voicehat.get_led()
if __name__ == "__main__":
led.set_state(voicehat.LED.PULSE_QUICK)
sleep(5.0)
led.set_state(voicehat.LED.BLINK)
sleep(5.0)
led.set_state(voicehat.LED.OFF)
while True:
pass- play_wave(wave_file)
- waveファイルを再生する
from __future__ import print_function
from time import sleep
import aiy.audio as audio
if __name__ == "__main__":
audio.play_wave("./he.wav")
while True:
passfrom __future__ import print_function
import aiy.voicehat as voicehat
import aiy.audio as audio
button = voicehat.get_button()
def _on_button_pressed():
print("Pushed")
audio.play_wave("./he.wav")
if __name__ == "__main__":
button.on_press(_on_button_pressed)
while True:
pass