pi@raspberrypi:~ $ irrecord --disable-namespace -f -d /dev/lirc1 --driver default ~/lircd.
conf
Using raw access on device /dev/lirc1
irrecord - application for recording IR-codes for usage with lirc
Copyright (C) 1998,1999 Christoph Bartelmus(lirc@bartelmus.de)
This program will record the signals from your remote control
and create a config file for lircd.
A proper config file for lircd is maybe the most vital part of this
package, so you should invest some time to create a working config
file. Although I put a good deal of effort in this program it is often
not possible to automatically recognize all features of a remote
control. Often short-comings of the receiver hardware make it nearly
impossible. If you have problems to create a config file READ THE
DOCUMENTATION at https://sf.net/p/lirc-remotes/wiki
If there already is a remote control of the same brand available at
http://sf.net/p/lirc-remotes you might want to try using such a
remote as a template. The config files already contains all
parameters of the protocol used by remotes of a certain brand and
knowing these parameters makes the job of this program much
easier. There are also template files for the most common protocols
available. Templates can be downloaded using irdb-get(1). You use a
template file by providing the path of the file as a command line
parameter.
Please take the time to finish the file as described in
https://sourceforge.net/p/lirc-remotes/wiki/Checklist/ an send it
to <lirc@bartelmus.de> so it can be made available to others.
Press RETURN to continue.
Checking for ambient light creating too much disturbances.
Please don't press any buttons, just wait a few seconds...
No significant noise (received 0 bytes)
Enter name of remote (only ascii, no spaces) :
Enter name of remote (only ascii, no spaces) :tv
Using tv.lircd.conf as output filename
Now start pressing buttons on your remote control.
It is very important that you press many different buttons randomly
and hold them down for approximately one second. Each button should
generate at least one dot but never more than ten dots of output.
Don't stop pressing buttons until two lines of dots (2x80) have
been generated.
Press RETURN now to start recording.
................................................................................
Please enter the name for the next button (press <ENTER> to finish recording)
channel1
Now hold down button "channel1".
Timeout (10 seconds), try again (29 retries left).
Now hold down button "channel1".
Please enter the name for the next button (press <ENTER> to finish recording)
Successfully written config file tv.lircd.conf
Press RETURN now to start recording.のところで、学習するボタンをひたすら押し続ける。
space 16777215
pulse 9059
space 4508
pulse 632
space 501
pulse 635
space 506
pulse 681
space 455
pulse 682
space 456
pulse 630
space 505
pulse 632
space 505
pulse 584
space 1684
pulse 681
space 455
pulse 584
space 1684
pulse 584
space 1684
pulse 584
space 1684
pulse 585
space 1684
pulse 585
space 1685
pulse 640
space 1581
pulse 689
space 1627
pulse 611
space 524
pulse 611
space 1658
pulse 615
space 523
pulse 615
space 1655
pulse 614
space 522
pulse 615
space 1655
pulse 613
space 1654
pulse 614
space 524
pulse 613
space 527
pulse 609
space 525
pulse 611
space 1658
pulse 588
space 549
pulse 608
space 1660
pulse 589
space 548
pulse 589
space 548
pulse 589
space 1679
pulse 592
space 1677
pulse 590
space 1675
pulse 594
pulse 13407
space 63383
space 40258
pulse 9119
space 2190
pulse 643
pulse 21195
space 121207
space 97010
pulse 9169
space 2141
pulse 688
pulse 22186
このデータの中から、一番最初の
space 16777215
と、後半の
pulse 13407 space 63383 space 40258 pulse 9119 space 2190 pulse 643 pulse 21195 space 121207 space 97010 pulse 9169 space 2141 pulse 688 pulse 22186
import RPi.GPIO as GPIO
import time
def __main__():
GPIO.setmode(GPIO.BCM)
GPIO.setup(21,GPIO.IN)
try:
while True:
out = GPIO.input(21)
if out == 0:
print(1)
else:
print(0)
time.sleep(0.0001)
except KeyboardInterrupt:
GPIO.cleanup()
__main__()
0.1ミリ秒周期で赤外線通信の受信信号を読み取って、0/1で出力するプログラムを作成してみました。
これを使用して、テレビのボリュームUP/DOWNの信号を読み取って、
こんなプログラムを作成して、赤外線LEDを点灯させるプログラムを作成。
import RPi.GPIO as GPIO
import time
pattern = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,
0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,
0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,1,1,1,0,
0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,
1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1]
def __main__():
GPIO.setmode(GPIO.BCM)
GPIO.setup(20,GPIO.OUT)
try:
for out in pattern:
GPIO.output(20, GPIO.HIGH)
time.sleep(0.0001)
GPIO.output(20, GPIO.LOW)
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.cleanup()
__main__()
import RPi.GPIO as GPIO
import time
pattern = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,
0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,
0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,
1,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1]
def __main__():
GPIO.setmode(GPIO.BCM)
GPIO.setup(20,GPIO.OUT)
try:
for out in pattern:
GPIO.output(20, GPIO.HIGH)
time.sleep(0.0001)
GPIO.output(20, GPIO.LOW)
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.cleanup()
__main__()