Stereo remote control
Wouldn't it be nice if I could use the hifi remote control to control mpd?
A friend of mine had a pile of IR receiver components in his stash and gave me one. It is labeled "38A 1424A", and the closest matching datasheet I found is this one.
I had to add these lines to
/boot/config.txt to enable
At first I had missed configuration of the internal pull up resistor, and reception worked but was very, very poor.
Install and configure
apt install lirc
I added these lines to
DRIVER="default" DEVICE="/dev/lirc0" MODULES="lirc_rpi"
systemctl stop lirc
Tested that the receiver worked:
mode2 -d /dev/lirc0
remote control codes for my hifi
and put them in
systemctl start lirc
Tested that lirc could parse commands from my remote control:
$ irw 0000400405506035 00 CD_PAUSE RAK-SC304W 0000400405506035 01 CD_PAUSE RAK-SC304W 0000400405506035 02 CD_PAUSE RAK-SC304W 0000400405505005 00 CD_PLAY RAK-SC304W 0000400405505005 01 CD_PLAY RAK-SC304W
I made this simple lirc program and saved it in
begin prog = irexec button = CD_NEXT config = mpc next end begin prog = irexec button = TAPE_FWD config = mpc next end begin prog = irexec button = TAPE_REW config = mpc prev end begin prog = irexec button = CD_PREV config = mpc prev end begin prog = irexec button = TAPE_PAUSE config = mpc pause end begin prog = irexec button = CD_PAUSE config = mpc pause end begin prog = irexec button = CD_PLAY config = mpc toggle end begin prog = debug button = TAPE_PLAY_RIGHT config = mpc toggle end
Then wrote a systemd unit file to start irexec and saved it as
[Unit] Description=Control mpd via lirc remote control After=lirc mpd [Service] Type=simple ExecStart=/usr/bin/irexec Restart=always User=pi WorkingDirectory=~ [Install] WantedBy=multi-user.target
systemctl start mpd-irexec to start irexec, and
systemctl enable mpd-irexec to start irexec at boot.
All of this was done by me, with almost no electronics training, following online tutorials for the hardware parts.
To connect components I used a breadboard and female-male jumper leads, so I didn't have to solder, for which I have very little practice.
Now the Raspberry Pi is so much a part of my hifi component that I can even control it with the hifi remote control.
Given that I disconnected the CD and tape players, there are now at least 16 free buttons on the remote control that I can script however I like.