"URC lets your home PC reach out and control many common appliances in your home – your CD player, TV, VCR, DSS, DVD, stereo preamp, radio tuner, cassette player, or anything else which accepts infrared remote control signals. I’ve given a very simple illustration in this column: pausing and muting everything when the phone rings. There are many other cool applications you can create."

Infrared Remote Control from your PC

Jonathan Somers

Infrared Remote Control from your PC
by Jonathan Somers

"URC lets your home PC reach out and control many common appliances in your home – your CD player, TV, VCR, DSS, DVD, stereo preamp, radio tuner, cassette player, or anything else which accepts infrared remote control signals. I’ve given a very simple illustration in this column: pausing and muting everything when the phone rings. There are many other cool applications you can create."

When he is not debugging the voicemail system at his house, Jonathan Somers is either enjoying a quiet life with his wife Jan and their
two daughters, or he is pursuing a bachelor's degree in computer science at the Georgia Institute of Technology. He also occasionally finds time for his regular job in the Mobile Computing Group of The Coca-Cola Company, helping consumers get their soft drinks a few seconds faster.


Wouldn’t it be great if your stereo would automatically turn itself down when your telephone rang? Or if you could call your VCR on the telephone and have it tape a certain show?

As with most home automation gadgets, I found several tools to let me operate infrared remote devices from a PC, but they all seemed to be lacking something on the software side. There was always some functionality I wanted to add, but couldn’t. What I really wanted was a program I could use right out of the box (so to speak), but could also customize so that it would behave exactly the way I wanted. Once I was convinced that I couldn’t find such a program, I decided it was time to write one.

This article will show you how to operate an infrared remote from your PC, and also teach you how to write simple programs letting you decide exactly how you want your remote-controlled appliances to behave.

About the One-for-All Remote Control

One-for-All (I’ll abbreviate to OFA) is a company that manufactures universal remote controls. These replace the many remotes that come with your TV, VCR, and stereo components with a single easy-to-use handheld. Once you program the OFA remote with the device codes that tell it the brand names and model numbers of your equipment, you can use one device to operate all your remote controllable appliances. Some OFA remotes even have the ability to operate the X-10 infrared remote receiver, so that you can operate lights and X-10 controlled appliances from a handheld remote control. More information on the OFA product line is available from www.oneforall.com.

This is already a nice feature for home automation, but many of the OFA remotes have an even better feature. Inside the battery compartment door are three holes that are the connections for a serial interface! OFA provided these holes so that they could customize the firmware inside the remote to add support for new appliances in the future. However, in addition to upgrading the device codes, you can also use this serial interface to operate the keys on the keypad.

While this interface is not RS-232 per se, you can easily purchase a cable that converts your PC’s RS-232 signals into the levels required by the OFA remote. If you’re handy with a soldering iron, you can build your own interface from some schematics I found on the Web at www.best.com/~ziggr/ir/adapterschematic.jpg. Since life is short and the cable can be had for less than $30 from various sources, I bought one ready-made.

There’s no connector per se inside the OFA remote – just three holes in the circuit board. Consequently while you can just plug the cable into these holes, the connection is intermittent and far from reliable. (Bear in mind that this interface was meant for short upgrades, not long-term control use.) Since I bought my remote specifically for PC control, I took it apart and soldered the cable in place. Needless to say, this voided my warrantee and also prevents me from ever carrying the unit around the house.

4005.gif (19416 bytes)Not all of the OFA remotes have the serial interface, and even among the ones that do, not all use the same protocols. I bought a URC-4005, which can control up to six different devices using the keypad. This remote uses a 9600-baud protocol that is far less sensitive to timing than some of the older remotes. The software I wrote should support not only the 4005, but also the URC-2005 and URC-6050 remotes (which use the same 9600-baud protocol). There may be other, newer remotes that also use this protocol.

If the remote control is attached to your PC, and your PC is not located with any of your controlled appliances, you will need some means to relay the infrared signals to where they are needed. I use the X-10 PowerMIDs in my house. I have three transmitters: one by my home automation PC, one in my rec room (mainly to operate the stereo in the great room), and one in my master bedroom (mainly to operate the VCR in the family room). I have one receiver at my stereo and another at my VCR; both have the optional tethers to drag the infrared from the pyramid to an IR LED on the controlled equipment. I have no complaints about the PowerMIDs, although I do notice that some unusual sources can cause them to trigger – in my home, the two main sources of interference are computer monitors and high-frequency fluorescent lighting (using solid state ballasts). Careful placement keeps these problems at bay. You can of course use any infrared distribution technology you choose.

Another quirk about the OFA as a computer interface: Most remotes only draw power while they are transmitting, but once you put the OFA into its PC-controlled mode, it draws power continuously. You can run your batteries down very quickly in this mode, so I dropped by the local Radio Shack and bought a 6V, 150mA AC battery eliminator (part #273-1454D). I cut the connector off (zounds! more warrantees voided) and permanently soldered the wires to the battery connectors; be sure you get the polarity right.

There is one final quirk you must know about. The OFA remotes require a manual step in order to put them into their PC control mode. Before the PC can start sending commands to the remote, someone has to physically push a button on the remote and then start the software within five seconds. Ugh! This becomes most troublesome if there is a power failure. My computer is already on a UPS, so I placed my battery eliminator into the spare UPS outlet so that my remote would always remain on and in the command state. I wrote the software accordingly – you can optionally exit this "command mode" when the program closes, or leave the remote in command mode so that the program can resume control without a pesky keypress when it restarts. It is not totally foolproof; when Windows reboots, the handshake lines may change and your remote can enter an undefined state. If you leave your PC alone and let it control your house without frequent reboots, you’re in for smooth sailing.

Running the URC Software

You can download my URC software from www.mindspring.com/~jons/downloads/urc.zip. The ZIP contains three files: a readme file, the URC.EXE program, and a URC.ODL file (which I will discuss later). If you don’t already have the Microsoft runtime .DLLs installed on your machine, you may need to download them as well – they are available from www.mindspring.com/~jons/downloads/mfc.zip.

wpe33.jpg (16281 bytes)The software is a Win32 program and, as such, requires Windows 95. It should work on 98 and Windows NT as well, since I don’t use any OS-specific features. The first time you run the program, it will prompt you to press a key on your remote. If you’re using COM1 and your remote is plugged and ready to go, you can do as it asks; otherwise just click on OK and you will have an opportunity to change COM ports in a moment.

The main window models the actual URC-4005 remote control. If you’re using a different remote, don’t panic – you can still get to all of the keys on your keyboard under program control. Between the Power and Magic keys at the top is a small window. Click your mouse on a few keys and you will see various numbers appear here; these are the actual bytes being sent through the serial interface. This can be very handy for debugging your own programs.

From the File menu, you can configure the only two options needed for this program. The first simply lets you select the COM port to which your remote is attached; you should enter the full name, such as "COM2" rather than just a 2. My machine has six COM ports installed, so unlike some programs that limit you to COM1-COM4, you can enter any port that appears in your Control Panel settings. (I actually use mine on COM6 routinely.) Changing ports does require you to exit and restart the program, but your choices are saved in the registry; you will not need to set them again unless you change the port to which your remote is attached.

The checkbox on the Settings dialog refers to the annoying keypress. Once you have pressed a key, started the software, and confirmed that the remote is responding to your PC, you can turn this checkbox off. Once you do this, the program will stop prompting you for a keypress when it starts. As long as your remote has power, it will remain in command mode even if you close the program. (Actually, my remote seems to withstand outages of a few seconds – perhaps there is enough capacitance in the AC adapter to sustain it briefly. Your PC may not, of course! I recommend a UPS if you can afford it.) If your remote ever seems to stop responding, try unplugging it and turning this checkbox back on.

Programming URC - The PhoneMute sample program

With URC in hand, you can quickly and easily create a program to perform one of my favorite home automation tricks: silencing the TV and stereo when the phone rings. This never fails to get "wow"s from visitors to the house, since it conveys the idea of a tightly integrated smart home.

Like the MediaCenter application in my last column, URC lends itself to OLE Automation because it is simply taking dictation. URC has a very simple server interface that lets you press the buttons inside the OFA remote – even buttons that do not appear on the URC-4005.

Having said that, a logical choice for my sample application is a simple twist on the PhonePause program for MediaCenter.

  1. Start Visual Basic. Create a new Standard .EXE, and immediately save it as PhoneMute.
  2. Set the name of the main form, and its caption, to PhoneMute.
  3. First things first: If you want to trigger an event when the phone rings, you need to learn about the ring from your modem. Go to the Project menu and select Components. On the Controls tab, check the box for "Microsoft Comm Control 5.0" and then press OK. A telephone and modem icon should appear on your tools bar.
  4. Select the phone/modem tool and draw a modem object on the lower-right corner of your main window. (This object will be invisible at runtime.)
  5. In the modem object’s properties, set the name of the object to "Modem" and set the comm port to the port on which your actual modem lives.
  6. Set the DTREnable and RTSEnable properties to True, and set the Rthreshold to 1. This will allow your program to receive strings from your modem; we will be watching for the "RING" strings.
  7. Set the Handshaking property to 2 – comRTS.
  8. Double-click on your Modem object, and enter the following code for its OnEvent method:
    Private Sub Modem_OnComm()
    Select Case Modem.CommEvent
    Case comEvReceive ' Received RThreshold # of chars
    Instring = Modem.Input
    If InStr(Instring, "RING") > 0 Then
    MsgBox ("RING")
    End If
    End Select
    End Sub
  9. Now double-click on your main form, and enter the following code for its Load method:
    Private Sub Form_Load()
    Modem.PortOpen = True
    Modem.Output = "AT" + Chr$(13)
    ' Wait for data to come back to the serial port.
    Loop Until Modem.InBufferCount >= 2
    ' Read the "OK" response data in the serial port.
    Instring = Modem.Input
    End Sub
  10. This is a good stopping point to make sure your program is working so far. Run the program and call your modem; you should get a message box every time the phone rings.
  11. Now let’s pull URC into your application. For this to work, you must have run URC at least once so that Windows knows where to find it. First create the Urc object at the application’s General level:
    Dim Urc As Object
  12. Back in your main form’s Load method, add the following lines at the top:
    Private Sub Form_Load()
    Set Urc = CreateObject("Urc.Application")
  13. Now let’s mute your TV set whenever the phone rings, and get rid of that silly message box. In your modem’s OnComm event, change the message box to:
    If InStr(Instring, "RING") > 0 Then
    Urc.PressButton( "TV" )
    Urc.PressButton( "MUTE" )
    End If
  14. Presto! You’re done. Want to pause your CD player or VCR? Just add the button pushes. The list of supported buttons is in the README file contained in URC.ZIP, but in almost every case the button name is identical to the legend on the physical remote control.


URC lets your home PC reach out and control many common appliances in your home – your CD player, TV, VCR, DSS, DVD, stereo preamp, radio tuner, cassette player, or anything else which accepts infrared remote control signals. I’ve given a very simple illustration in this column: pausing and muting everything when the phone rings. There are many other cool applications you can create. Here are some ideas to get you started:

  • Why stop with the phones? Put an X-10 Powerflash on your doorbell and mute the equipment whenever someone is at the door.
  • If you have a voice-capable modem that can decode touch tones, you can call your home while away and send commands to program your VCR from afar. That way, if you leave a blank tape in your VCR, you can call your house and have it tape shows while you’re away.
  • If you have decent voice recognition software, you can forget about cable channel numbers. Put a wireless mike in your living room to replace that old remote control. If you want to watch ESPN, just say "ESPN" and have your computer remember the channel numbers for you.
  • Even if your VCR cannot decode VCR Plus codes, you can get a shareware program to convert VCR Plus codes into date/time/channel information. Then your PC can command your VCR to tape the correct channels at the right times.

Comments (0)

This post does not have any comments. Be the first to leave a comment below.

Post A Comment

You must be logged in before you can post a comment. Login now.

Featured Product

Video Mount Products ERWEN-6E Wall Mounted Rack Enclosure

Video Mount Products ERWEN-6E Wall Mounted Rack Enclosure

Beautiful and strong, the ERWEN-6E is a workhorse of a wall mounted rack enclosure. With adjustable four post rails, a 120 lb. load capacity, black powder coat finish, ships fully assembled, a removable hinged wall plate and a reversible tempered glass front door, the ERWEN-6E has all the features installers are looking for. www.videomount.com. MSRP: $339.00