-
-
Save seiyashima/971e7d3f8bb2fa3cb42f4e91d27d1d4c to your computer and use it in GitHub Desktop.
【初心者向け】Raspberry Pi 3 MODEL B + Slack でエアコンのリモコンを作ってみた ref: https://qiita.com/shIbaInu42/items/02f93e865920e08dc5c6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# airconbot can turn on as cooler or heater depends on commands | |
# and turn off the room aircon | |
# | |
# userID(userlist from Slack) | |
uid = [ 'UXXXXXXXXX' ] # 2.2節で取得したユーザーIDを入力 | |
# For executing script from coffeeScripts | |
cp = require 'child_process' | |
oshushi = (command, success, msg) -> | |
if msg.message.user.id in uid | |
cp.exec "sudo ./wirPi/sendir ./wirPi/#{command}Ir.data 1", (error, stdout, stderr) -> | |
if !error | |
msg.reply "#{success}" | |
else | |
msg.reply "#{error}" | |
else | |
msg.reply '知らない子ですねぇ。。。' | |
module.exports = (robot) -> | |
robot.respond /heat/i, (msg) -> | |
oshushi('heat', '暖房のスイッチを入りぇたよ!', msg) | |
robot.respond /cool/i, (msg) -> | |
oshushi('cool', '冷房のスイッチを入りぇたよ!', msg) | |
robot.respond /off/i, (msg) -> | |
oshushi('off', 'エアコンのスイッチを切りゅよ!', msg) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
項番|名称 |型名 |価格 |入手元 |備考 | |
------------------------------------------------------------------------------------------------------------ | |
1|赤外線リモコン受信モジュール |GP1UX511QS|¥ 100|千石電商(@秋葉原)|特に無し | |
2|丸形赤外線LED |SID1K10CM |¥ 65|マルツ(@秋葉原) |Gistで挙げたモノに放射強度、ピーク発光波長が近いものを購入。 | |
3|丸形LED拡散キャップ |不明 |¥ 50|マルツ(@秋葉原) |特に無し | |
4|抵抗 (270Ω: 1個) |不明 |¥ 30|自分の道具箱 |特に無し | |
5|ジャンプワイヤ(オスメス: 3本) |不明 |¥ 54|Amazon.com |40本セットを購入し、セット価格が18円/本であったことに基づく。 | |
6|ジャンプワイヤ(固い&短い) |不明 |¥ 0|自分の道具箱 |Arduino UNOのキットに入っていたものを流用。 | |
------------------------------------------------------------------------------------------------------------ | |
合計|¥ 299| ※あくまで目安です。 | |
------------------------------------------------------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd <プログラムを置きたい階層: (例)/etc/dev> | |
$ git clone git://git.drogon.net/wiringPi | |
$ cd wiringPi | |
$ ./build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://slack.com/api/users.list?token=<取得したトークン: (例)xoxbXXXXXXXXXXXXXX> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gpio version: 2.42 | |
Copyright (c) 2012-2017 Gordon Henderson | |
This is free software with ABSOLUTELY NO WARRANTY. | |
For details type: gpio -warranty | |
Raspberry Pi Details: | |
Type: Pi 3, Revision: 02, Memory: 1024MB, Maker: Embest | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gpio -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo ./scanir coolIr.data 29 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OS: Mac OS X 10.10.5 Yosemite | |
Memory: 8GB | |
CPU: 2.66GHz | |
Raspberry Pi: 3 MODEL B (Amazonで ¥5,780 で購入。) | |
※別途、モニタ、モニタとRaspberryを接続するコード、電源コード、microSDHCなどが必要となります。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo ./scanir heatIr.data 29 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo ./sendir coolIr.data 28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo ./sendir heatIr.data 28 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment