工業局生醫電子

2015年5月7日 星期四

Raspberry Pi 使用紅外線



硬體準備


一個IR 發射器及一個接收器 (使用Raspberry pi Education Kit)




LIRC 軟體安裝及設定


We need to install LIRC and client libraries.
pi@raspberrypi ~ $ sudo apt-get install lirc liblircclient-dev

snd-bcm2835
i2c-dev
lirc_dev
lirc_rpi gpio_in_pin=25


# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false

#Don't start irexec, even if a good config file seems to exist.
#START_IREXEC=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="UNCONFIGURED"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"

MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
Reboot



快速測試

To perform a quick test to see if LIRC is working, we need to stop the LIRC daemon and start mode2. mode2 shows the the pulse/space length of infrared signals.

pi@raspberrypi ~ $ sudo /etc/init.d/lirc stop
pi@raspberrypi ~ $ mode2 -d /dev/lirc0

When buttons are pressed on your remote, mode2 will give a similar output to what is shown below.

1
2
3
4
5
6
7
8
9
10
pulse 627
space 514
pulse 624
space 513
pulse 599
space 521
pulse 618
space 1668
pulse 589
space 532

進階IR 程式解析



參考資料:  




沒有留言 :

張貼留言