Raspberry Pi Zero W で赤外線リモコン ユニバーサル基板に実装 [Raspberry Pi]
Rasberry Pi Zero 用のユニバーサル基板に赤外線レシーバーと赤外線LEDを実装した。
構成部品や配線は,8月にブレッドボードで作成したこちらと同じ。
ラズパイにUSBウェブカメラを接続して,CLIプログラムの操作でCDのトレイが開いたところを motion というパッケージでブラウザに表示した。
試作したCLIプログラムの内容は以下のとおり。押したショートカットキーに応じて赤外線送受信の既製のサンプルプログラム irrp.pyをキックしているだけである。
http://abyz.me.uk/rpi/pigpio/examples.html#Python%20code
IR Record and Playback
また,TANGENT.dat というリモコンデータのファイル(これは自分で作った。こちら参照)も irrp.py に渡すために必要。
import os, curses
def main(stdscr):
curses.echo()
stdscr.clear()
stdscr.addstr(0, 0, '+-------+-------+--------+---+---+---+' )
stdscr.addstr(1, 0, '|OEPN(s)|PWR (o)| | 1 | 2 | 3 |' )
stdscr.addstr(2, 0, '+-------+-------+--------+---+---+---+' )
stdscr.addstr(3, 0, '|PLAY(p)|STOP(t)| | 4 | 5 | 6 |' )
stdscr.addstr(4, 0, '+-------+-------+--------+---+---+---+' )
stdscr.addstr(5, 0, '| |<-(r)| ->|(f)| | 7 | 8 | 9 |' )
stdscr.addstr(6, 0, '+-------+-------+--------+---+---+---+' )
stdscr.addstr(7, 0, '| <<-(a)| ->>(g)| |10+| | |' )
stdscr.addstr(8, 0, '+-------+-------+--------+---+---+---+' )
stdscr.addstr(9, 0, '|V_DN(d)|V_UP(u)| | | | |' )
stdscr.addstr(10, 0, '+-------+-------+--------+---+---+---+' )
stdscr.addstr(11, 0, '|MUTE(m)|CD (c)|Quit(q) | | | |' )
stdscr.addstr(12, 0, '+-------+-------+--------+---+---+---+' )
stdscr.addstr(14, 0, ': ' )
stdscr.refresh()
while True:
stdscr.addstr(14, 2, ' ')
c = stdscr.getch()
if c == ord('q'): break
elif c == ord('s'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_OPEN')
elif c == ord('p'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_PLAY')
elif c == ord('t'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_STOP')
elif c == ord('d'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat VOL_DOWN')
elif c == ord('u'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat VOL_UP')
elif c == ord('m'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat MUTE')
elif c == ord('c'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat CD')
elif c == ord('o'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat POWER')
elif c == ord('f'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat SKIP_FWD')
elif c == ord('r'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat SKIP_REV')
elif c == ord('a'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat SCH_FWD')
elif c == ord('g'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat SCH_REV')
elif c == ord('1'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_1')
elif c == ord('2'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_2')
elif c == ord('3'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_3')
elif c == ord('4'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_4')
elif c == ord('5'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_5')
elif c == ord('6'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_6')
elif c == ord('7'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_7')
elif c == ord('8'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_8')
elif c == ord('9'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_9')
elif c == ord('0'): os.system(
'python3 irrp.py -p -g17 -f TANGENT.dat KEY_10CHANNELSUP')
if __name__ == '__main__':
curses.wrapper(main)
TANGENT.dat
{"CD": [9079, 4415, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 479, 643, 479, 643, 1607, 643, 479, 643, 479, 643, 1607, 643, 479, 643, 1607, 643, 479, 643, 1607, 643, 479, 643, 1607, 643, 1607, 643, 479, 643, 1607, 643, 479, 643, 1607, 643, 40955, 9079, 2174, 643, 96065, 9079, 2174, 643],
"MUTE": [9079, 4415, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 479, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 1607, 643, 479, 643, 479, 643, 479, 643, 1607, 643, 479, 643, 1607, 643, 479, 643, 479, 643, 479, 643, 1607, 643, 1607, 643, 479, 643, 1607, 643, 479, 643, 1607, 643, 1607, 643, 1607, 643, 40955, 9079, 2174, 643, 96065, 9079, 2174, 643],
"POWER": [9084, 4400, 645, 477, 645, 477, 645, 477, 645, 477, 645, 477, 645, 477, 645, 477, 645, 477, 645, 1602, 645, 1602, 645, 1602, 645, 1602, 645, 1602, 645, 1602, 645, 1602, 645, 477, 645, 477, 645, 1602, 645, 1602, 645, 1602, 645, 477, 645, 477, 645, 1602, 645, 477, 645, 1602, 645, 477, 645, 477, 645, 477, 645, 1602, 645, 1602, 645, 477, 645, 1602, 645, 40953, 9084, 2059, 645],
(以下省略)
トランジスタで赤外線LEDへの電流を増幅しているようだが,赤外線が弱いのか,2.5m位しか届かない。
トランジスタは1815Lだが,これでは赤外線LEDを十分な明るさで点灯できないらしい。
8月にブレッドボードで試作した時と構成は変わってないが,さらに弱くなった気がする。
こちらの説明のように,トランジスタを1815から別のものに変えて作り直すか既製品を買うかである。
ユニバーサル基板に実装は,電子工作のキャリアがないのに場当たり的にやって送受信共に動いたので最初は喜んだが,送信が弱い。トランジスタを変える等で,普通のリモコン並みに強化したい。
コメント 0