Any remote will do.
I'm using a logitech universal remote (harmony 300), which is programmed to replace my sony-stereo's remote. The Pi's audio is connected to my stereo. If my stereo is set to AUX, most of the button on the remote don't do anything. So I use those buttons to control the Pi.
Kind of a strange setup, but it works for me.
I did run into one problem, that is, that the sony remote sent out 2 different lengths of pulses. I don't think many remotes will have this though. I fixed by making lirc think that the shorter code where from a different remote (you can setup LIRC to use multiple remotes at the same time).
So here come the instructions for how I set up things:
Connect the TSOP plus to the 3.3V, and ground to ground. I connected the OUT to GPIO 4, which is pin 7 on the board. I added a 2.2K resister just to be sure. Note that lirc_rpi defaults to using PIN12 (GPIO18) for input, and PIN11 (GPIO17) for output. If these pins are free, using those pins would be preferable. The output is for a IR blaster, but I don't need that. So I set output to GPIO 7 as that one isn't connected in my setup.
You'll need the lirc_rpi module. This is available in the latest kernel. Check if it is available in your system by running `find /lib/modules/ -name *lirc_rpi*`. If nothing is found do the following to upgrade the kernel
Code: Select all
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update
sudo apt-get install git-core
sudo rpi-update
Install lirc
Now load the lirc_rpi module (change gpio number is you are using different ones. note that these are gpio numbers, not pin numbers)
Code: Select all
sudo modprobe lirc_rpi gpio_in_pin=4 gpio_out_pin=7
Now to test run
Now press some buttons on the remote. You should see a whole lot of space and pulse lines.
Now config lirc. run `sudo pico /etc/lirc/hardware.conf` and
change the following lines
Code: Select all
...
LIRCD_ARGS="--uinput"
...
DRIVER="default"
...
DEVICE="/dev/lirc0"
If you are using the default pins, you could also change `MODULES=""` to MODULES="lirc_rpi"
Now we need to led lirc learn the IR-commands sent by the remote.
Code: Select all
sudo /etc/init.d/lirc stop
irrecord -n -d /dev/lirc0 ~/lircd.conf
#follow the instructions on the screen
#just learn a few button. Do the rest once everything is working.
#now copy this newly created conf file
sudo mv ~/lircd.conf /etc/lirc/lircd.conf
#start lirc
sudo /etc/init.d./lirc start
#now run irw to check everything
irw
#now press the button on the remote you just learned. The commands should appear on the screen
If all this works go and create some actions to be performed on IR-input. Run `pico ~/.lircrc` and type something like:
Code: Select all
begin
prog = irexec
button = pause
config = mpc toggle
end
begin
prog = irexec
button = nextsong
config = mpc next;mpc play
end
begin
prog = irexec
button = prevsong
config = mpc prev;mpc play
end
begin
prog = irexec
button = stop
config = mpc stop
end
Change the `button=xxx` so xxx is the name you provided when running irrecord. Add more when needed.
Next we need to run irexec as a background process
Now press e.g. the play button and see/hear what happens.
Final this to do is have modprob and irexec run on startup. To do this edit /etc/rc.local. `sudo pico /etc/rc.local`
Code: Select all
#before exit 0 past the following
(sleep 5;
sudo modprobe lirc_rpi gpio_in_pin=4 gpio_out_pin=7
sleep 5;
sudo -u pi irexec -d
#note: irexec can't run as root. Also note it shuts down if lircd is restarted
)&
(skip the modeprobe line I you are using default pins, and have set `MODULES=lirc_rpi` in hardware.conf)
I think that is about it. Please let me now if you run into any problems. Or if you get it working, of course.
Good luck