Magazines: AutoSpeed  |  Rallysport  |  V8X  |  Silicon Chip  Shopping: Property  |  Cars  |  Fishing
Email Address:

Lost your password?

Article Search

PICAXE Infrared Remote Control

Here's how to add infrared remote control to all your PICAXE-08M projects (including Rudolph)

By Clive Seager


In the September 2004 issue, we showed you how to assemble "Rudolph the Red-Nosed Reindeer". Rudolph is a simple Christmas decoration with flashing LEDs that can play a variety of tunes, including mobile phone ring tones. As promised, this month we assemble the infrared remote transmitter and add the receiver components to Rudolph’s PC board.

Before we describe how to assemble the various pieces, let’s first take a look at the basics of infrared transmission on the new PICAXE-08M.

Infrared remote control

The PICAXE-08M includes two commands for sending and receiving data over an infrared link. The infraout command sends data on pin 7, whereas the infrain2 command receives data on pin 3. Data is transferred using a simple modulation technique based on the well-documented Sony Infrared Remote Control System (SIRCS) protocol.

Click for larger image
Fig.1: basics of the SIRCS protocol, showing the composition of each serial transmission. A logic "1" is represented by a 1.2ms burst of the 38kHz carrier, whereas a logic "0" is represented by a shorter 0.6ms burst. Each bit is separated by a gap of 0.6ms.

The SIRCS protocol uses a 38kHz modulated infrared signal consisting of a start bit (2.4ms) followed by 12 data bits (7 data bits and 5 device ID bits). Logic level "1" is transmitted as a 1.2 ms pulse, logic ‘0’ as a 0.6ms pulse. Each bit is separated by a 0.6ms gap (see Fig.1).

When used within Sony production devices, the 5 device ID bits represent the type of equipment (1 = TV, 2 = video, 26 = DVD, etc). The 7 data bits represent different commands (1 = channel 2, 2 = channel 3, 16 = channel up, 20 = mute, etc). Within this PICAXE project the Sony-allocated commands are not relevant, but a full list is provided in the PICAXE manual for those interested in controlling their own Sony hardware!

Sending data

To transmit infrared data, the PICAXE command is:

infraout device,data

For example, to send the Sony command "TV - mute", the command would be infraout 1,20. Note that device should always be 1 when used in PICAXE projects and data can only be between 0 and 127, as the SIRCS protocol only specifies 7-bit capability.

The full program for the transmitter is shown in Fig.6. As infrared signals are easily corrupted, the data is actually sent 10 times to increase reliability. This matches commercial remote controls that tend to transmit the data at 45ms intervals whilst the button is held down.

Note that the program uses codes "1", "2" and "3" for the three switches, but you can edit these to any number between 0 and 127. This would be useful when you want to control multiple units in the same room, using different data commands for each unit.

Building the transmitter

As hinted at in September, the various tunes played by Rudolph can be triggered remotely using an infrared transmitter. This simple project uses a PICAXE-08M micro, three push-button switches and an infrared LED to make a complete hand-held remote, the circuit for which appears in Fig.2. A second visible LED is included for user feedback.

Click for larger image
Fig.2: circuit diagram for the simple infrared transmitter. As no serial link socket is provided, the PICAXE chip must first be plugged into the "Rudolph" PC board (described in September 2004) for programming.

Assembly is very straightforward and should only take a few minutes. Begin by installing a wire link in the position indicated by a dotted line on the overlay diagram (Fig.3). An off-cut resistor leg is ideal for the job. Note that as an IC socket will be mounted over the link, it must be lying flat on the PC board before soldering.

Install all of the resistors, switches and IC socket next, making sure that you have the notched (pin 1) end of the socket around the right way.

Install the two LEDs next, noting that the infrared LED (IRLED1) leads must be bent at 90 degrees so that it points away from the PC board (see photo). Make sure that you have the flat (cathode) sides of the LEDs oriented correctly. The infrared LED may be supplied in either a "black" or "water clear" epoxy package.

Finally, solder the battery leads to the positions indicated after threading through the adjacent hole. Note that the board runs from a 4.5V (3 x AA) battery pack – do not connect a 9V PP3 battery!

To reduce overall size, a serial link socket is not provided on the transmitter PC board. Therefore, the PICAXE-08M chip must be programmed on the main Rudolph PC board and then transferred to the transmitter board.

Click for larger image
Fig.3: the overlay diagram for the infrared remote transmitter. Install the wire link (under IC1) first, then all the other parts, making sure that the IC socket is around the right way.

After assembly and programming, you can check transmitter operation by looking at the infrared LED "end-on" through a webcam or digital camera (such as a mobile phone camera). Although the LED is not visible to the naked eye, these camera are sensitive to infrared light and so the infrared LED will display a faint glow on the camera screen whilst operating.

Fig 6: Transmitter Program Listing

' Wait until switch press
if pin1 = 1 then tx_1
if pin2 = 1 then tx_2
if pin3 = 1 then tx_3
goto main

let b1 = 1 - 'Code 1
goto tx_ir

let b1 = 2 - 'Code 2
goto tx_ir

let b1 = 3 'Code 3
goto tx_ir

' Transmit code 10 times for increased reliability
high 4 - 'visual LED on for user feedback
for b2 = 1 to 10 - 'send infrared code 10 times
infraout 1,b1
pause 45
next b2
low 4 'LED off
goto main

Legs Versus Pins

In PICAXE BASIC, "pin" refers to a logical input or output port number, not a physical pin. Conversley, physical pins are referred to in the PICAXE documentation as "legs". Confused? We’re not surprised.

When describing a PICAXE circuit, SILICON CHIP will continue to refer to physical pins as "pins", just as we do for all our projects. We’ll leave the legs for the organic world! (Editor.)

Extending transmitter range

A 330Ω resistor is used in series with the infrared LED to limit current flow from the PICAXE port pin to an acceptable level. This gives a transmission range of about 4-5 metres, which should be enough for most users.

Click for larger image
Fig.4: transmission range can be increased by adding an external transistor circuit to drive the infrared LED.

However, infrared LEDs can typically be driven with a much higher current, thus extending the potential transmission range. If you need the maximum possible range, then a transistor driver circuit can be added between the PICAXE infrared output pin and the LED, as shown in Fig.4.

Receiving data

The infrared receiver portion of the "Rudolph" circuit from last month is reproduced in Fig.5. Any PICAXE-08M project can receive infrared remote control signals with the additional of these four components.

A Vishay TSOP4838 infrared receiver IC demodulates the 38kHz carrier wave to give a logic output. It also contains filters to suppress noise signals from devices such as fluorescent lights. The block diagram of the receiver is shown in Fig.8.

To receive infrared data, the PICAXE command is simply: infrain2

This command waits for a valid input signal and then stores the data in a variable named "infra". This variable can then be used to play different tunes, as shown in the full receiver program in Fig.7.

Click for larger image
Fig.5: any PICAXE-08M can receive infrared remote control signals with the addition of just a few components, as shown here.

As the PICAXE-08M uses the standard SIRCS protocol, the receiver will also work with commercial "universal" style infrared remote transmitters. These are widely sold as "one-for-all" replacements for use with home audio and video equipment. All you need to do is program them with one of the Sony-compatible equipment codes from the supplied list of manufacturers codes.

Fig 7: Receiver Program Listing

' ***** main loop *****
infrain2 - 'wait until infrared signal
'debug infra - 'optional display on screen for testing

' ***** play tune *****
'play tune depending on light level
if infra = 3 then play_xmas
if infra = 2 then play_rudolf
if infra = 1 then play_jingle
goto main

play_jingle - 'internal tune Jingle Bells
play 1,3
goto main

play_silent - 'internal tune Silent Night
play 2,3
goto main

play_rudolf - 'internal tune Rudolf The Red Nosed Reindeer
play 3,3
goto main

play_xmas - 'external ring tone tune

'We Wish You a Merry Xmas
tune 3, 4,($22,$27,$67,$69,$67,$66,$24,$24,$24,$29,$69,$6B,$69,$67,

goto main

Rudolph upgrade

Only two parts remain to be added to the Rudolph PC board. The receiver IC is soldered into the "IR" position, with the leads bent over so that it lies flat on the board.

A 4.7µF capacitor is also added to filter the supply, noting that the positive lead goes in as indicated by the "+" marking on the overlay diagram. The 330Ω and 4.7kΩ resistors should already be installed on the board, as they were part of the original assembly.

Finally, reprogram Rudolph with the BASIC code listed in Fig.7, which adds the necessary infrared remote control functions. That done, you should be able to choose between three tunes using the buttons on your remote control board!


With a minimum of external components and the new infraout and infrain2 commands, you can add remote control capability to all of your PICAXE-08M projects. "Rudolph the Red-Nosed Reindeer" demonstrates how it all works, and might even be a party favourite come Christmas!

Click for larger image
Fig.8: this diagram reveals the basic functional blocks within the TSOP4838 infrared receiver. As well as the actual PIN (photo) diode, it includes amplifier, discrimination and demodulation circuits to reconstruct the original digital data, which appears on the "OUT" pin.

Part Lists

1 infrared PC board

3 miniature pushbutton switches (S1 - S3)

1 battery clip

1 3 x AA battery holder

1 8-pin IC socket


1 PICAXE-08M (IC1)

1 Vishay TSOP4838 infrared receiver IC

1 5mm yellow LED (LED)

1 5mm infrared LED (IRLED)


1 4.7µF 16V PC electrolytic

Resistors (0.25W 5%)

3 10kΩ

2 330Ω

Also required (not in the kit)

Rudolph kit (part no. AXE107S)

PICAXE Programming Editor software (v4.1.0 or later)

PICAXE download cable (part no. AXE026)

3 x AA alkaline cells

Obtaining kits & software

The design copyright for this project is owned by Revolution Education Ltd. Complete kits (Part No. AXE108S) and/or the Vishay infrared receiver (Part No. LED020) for this project are available from authorised PICAXE distributors – see or phone Microzed on (02) 6772 2777.

The PICAXE Programming Editor software can be downloaded free of charge from or ordered on CD (part no. BAS805).

The following downloads are available for this article:

Privacy Policy  |  Advertise  |  Contact Us

Copyright © 1996-2005 Silicon Chip Publications Pty Ltd & Web Publications Pty Limited. All Rights Reserved