# IR Setup

The Pinscape unit can send and receive IR commands if you have the necessary extra components attached. To send commands, you need an IR LED; to receive, you need an IR sensor (TSOP38438 or equivalent). The transmit and receive capabilities are independent, so you can attach either or both components. The Build Guide has details on what you need and how to attach everything to the KL25Z.

## IR Command List

You can program the Pinscape device with a list of IR commands learned from the remote controls for your TV(s) and other devices.
An IR "command" is the signal sent when you push a button on one of your remotes. Each button generally has a unique IR signal associated with it. Pinscape can learn these signals and store them in the command list, and then use the stored commands to repeat the same commands via its IR transmitter, and to recognize the commands when they come in on its receiver.
Each entry in the IR Command List has the following elements:

- IR Code: this is a magic number representing a particular IR command. In most cases, you'll want to obtain these codes using the "learn" function.
- Learn (): Click this button to bring up the "learn" dialog, which lets Pinscape learn a code by reading the IR signal from one of your remotes through the Pinscape IR receiver.
- Test (): Click this button to test a code by transmitting it through the Pinscape IR LED. This lets you confirm that the target device gets the signal when Pinscape sends the code.
- TV ON (): Click this to include the IR command in the TV ON sequence when the system powers up. This lets you turn on your cabinet TV(s) with IR commands.
- Key (): Click this to select a keyboard key or joystick button to send to the PC whenever Pinscape receives the IR code. This lets you use a remote control to send key presses to the PC.
- Description: You can fill this in with the name of the remote control button programmed into the slot ("Vizio TV ON", say). This is purely optional. It's just a memory jogger to help you keep track of what's programmed where, since the "IR Code" field is pretty cryptic by itself.

## IR Code Numbers

Each IR Code is a magic number that tells the Pinscape firmware how to read and send a particular remote control code. It's "magic" in that it's really only meaningful within the Pinscape software. The number encodes the type of infrared signal protocol the remote uses (these vary by manufacturer, and there are many) and the data bits contained in the IR signal.
The best way to determine a code is to use the "learn" function, which lets Pinscape determine the code for a particular remote button by reading the signal that your remote sends when you press the button. You can also simply type in a code if you happen to know the number, such as by getting a code from another Pinscape user. But you can't generally use code numbers you might see published in third-party IR code tables on the Internet, since every table uses its own numbering system that probably doesn't match the Pincsape format.

## Things Pinscape can do with IR

You can use the IR capabilities in several ways:

- Turn on your cabinet TV(s) when the system starts up
- Send key presses to the PC on receiving an IR command
- Transmit IR commands when you push a cabinet button

These are all described in more detail below.

## TV ON with IR

The IR transmitter can be used to turn on your cabinet TVs when the system starts up. This is a less invasive alternative to the hard-wired TV ON feature (where you have to open the TV's case and solder wires to your TV's "on" switch). With IR, you don't have to do any surgery on the TV.
If you haven't already configured the basic TV ON settings, you'll have to set that up first. Go to the TV ON section in the settings, enable it, set the delay timer, and set up the input pins. If you're not using the Pinscape expansion boards, you'll need to build some external circuitry, which is explained in the Build Guide. The "Power status input" and "Status latch output" parts are required. The "Relay output" isn't required if you're only using IR (but it's also okay to use both IR and the relay; they're happy to work together or separately).
Next, set up the Pinscape IR transmitter LED and position it so that your TV can see the commands it emits. See the Build Guide for instructions on wiring the IR LED. Position the LED so that it's near to and pointing at the remote control sensor window on the TV.
All that remains is to program the TV's "ON" command into a slot in the IR code list. Get out your TV's remote, and program the ON button into a slot as described above. Click the TV ON icon () to include the command in the power-up sequence. Pinscape will now transmit this command through its IR transmitter when the power comes on, after the delay timer finishes.

## Send a key press on receiving an IR command

You can program the Pinscape unit to send a key press to the PC on receiving an IR command.
For example, suppose you want to be able to adjust the audio volume on your PC, but you don't have any spare buttons on your cabinet. And suppose you have an old remote control lying around for something you're no longer using, and it has some kind of Up and Down keys. You can program Pinscape so that it sends a keyboard "Volume Up" key to the PC when you press the Up button on the remote, and a keyboard "Volume Down" when you press Down on the remote.
To use this feature, you'll need to set up the Pinscape IR sensor, and position it so that it can see IR light from your remote. This means positioning the sensor outside the cabinet, or through a hole in the cabinet. You can't place it entirely inside the cabinet, since IR light from the remote won't penetrate the cabinet walls.
Now go to the IR Command List in the settings. Program in the remote control button codes, as described above, for the buttons that you want to turn into keystrokes. For each one, click the "Key" icon () to select the key to send. Once that's all set up, Pinscape will "press" the programmed key whenever it receives the corresponding IR command.

## Send an IR command when you press a cabinet button

You can program Pinscape to transmit an IR command whenever you press a cabinet button.
For example, suppose that you want to be able to adjust your TV's volume via cabinet buttons. To do this, you can configure buttons on your cabinet to send Volume Up and Volume Down commands to the TV via IR.
To make this work, you need to set up the Pinscape IR transmitter LED, as explained in the Build Guide, and position the LED so that the TV's remote control sensor can see it. This is the same arrangement needed for the TV ON feature via IR, so you probably already set that up.
Now you just need to assign an IR command to each button that you want to use to send IR signals to the TV. The first step is to program the IR command codes that you want to send. Program the desired commands into slots in the IR command list as described above.
Once you have the IR commands programmed, go to the Buttons section in the settings. Find the row for the button that you want to use to send an IR command, and click the IR Command icon in the row (). Select the desired IR command from the menu.