LoginSignup
25
21

More than 5 years have passed since last update.

家に帰ると小林さんちのメイドラゴンのカンナちゃんが「おかえりー」って言ってくれる装置を作った

Last updated at Posted at 2017-03-31

動機

ねえ、カンナちゃん可愛すぎない?帰ってきておかえりって言ってくれたら最高じゃない?というわけで作った。

使うもの

・人感センサー(SB412A)
・Raspberry Pi3
・ブレッドボード
・ジャンプワイヤー
・スピーカー(3.5mmプラグ)

ライブラリインストール

mp3を再生するにはライブラリが必要なので再生するためのライブラリのmpg321をインストールする

sudo apt-get install mpg321

配線

人感センサーをRaspberry PiのGND、5V、25ピンにそれぞれ繋ぐ

音源

11話のニコ動公式配信から取ってきた(3分40秒付近)
okaeri.mp3という名前でpythonと同じディレクトリにおいておく

コード

小林さんが書いてたPythonを使う。

okaeri.py
# -*- coding: utf-8 -*-
from __future__ import print_function
import socket
import commands
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.IN)
from contextlib import closing

def main():

  while True:
    inputValue = GPIO.input(25)
    if (inputValue == True):
      okaeri()
    time.sleep(10)

def okaeri():
    print("おかえりー")
    #mp3再生コマンド実行
    check = commands.getoutput("mpg321 okaeri.mp3")

if __name__ == '__main__':
  main()

動画

ニコ動にもあげた(宣伝)
家に帰るとカンナちゃんが「おかえりー」って言ってくれる装置作った!

参考

RaspberryPiで人感センサーを作る

25
21
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
21