For part two of this project, we will use the decoded infrared signal data from part one to control the stepper motor.

Looking Backward and Forward

Part one of this project described the principles of IR (infrared) signaling in general, and the SIRC (Sony Infrared Remote Code) in particular. A receiver circuit was presented to detect, decode, and display the information contained in the SIRC signals using a PICAXE microcontroller.

Part two of the project will build on that foundation by revisiting the 28BYJ-48 unipolar stepper motor that was introduced in a prior article. In addition, an IR transmitter circuit will be presented that is easy to build and use with the home-built receiver and a ULN2003A and that allows us to remotely start, stop, and control the rotational direction of the stepper motor. The appropriate code will be included for both the SIRC transmitter and receiver.


The Receiver Hardware

In part one, you were shown how to build an SIRC receiver on a solderless breadboard, and you were advised to duplicate the layout presented as closely as possible. If you compare that circuit to the one below, you will see that only a few parts have been added.


Click to enlarge


Compared to the last circuit in part one, there are only two new electronic parts (U3 and C2), one new connector (EXM1), and six new wires: one each of black, white, blue, yellow, green, and red. The black wire connects common ground to U3, the red wire brings +5V to U3 and the stepper motor, and the white, blue, yellow, and green wires connect control signals from U1 to U3. In addition, the 28BYJ-48 stepper motor has been connected. A cable of five wires connects the output of U3 (through EXM1) to the stepper motor.



In the photo above, note that leg 1 of U1 (the PICAXE 08M2) is located to the lower left in the breadboard photo, and leg 1 of U3 (the ULN2003A) is located to the upper right; this arrangement makes connecting the two ICs much easier. Leg 1 of U1 and leg 1 of U3 are identified in the photo by a white dot or splotch on the body of the chip.



You may recall from this article that the 28BYJ-48 stepper motor often comes with its own driver board, as shown in the photo above. While that is helpful in some applications, the motor is also available without the driver board. Connecting the driver board to a solderless breadboard and then to the motor produces an unwieldy mechanical arrangement. In addition, the four LEDs and resistors on the driver board are of limited usefulness.

In this case it's easier to forego the driver board; simply plug the ULN2003A directly into the solderless breadboard and connect the motor via EXM1. Plug the motor cable into the EXM1 connector first, and then plug the EXM1 connector into the solderless breadboard. Note that EXM1 makes good electrical connections to the breadboard, but is easily dislodged.


Parts List

In addition to the receiver components listed in part one of this project, you will need those in the table below.


Part Ref. Description Source Item No.
U3 IC, Darlington Pairs, 7-circuit, ULN2003A Digi-Key* 497-2344-5-ND
C2 Capacitor, Ceramic, 0.1µF, 50V Digi-Key 399-9797-ND
EXM1 Connector, PCB Mount, 5-pin, Top Entry Digi-Key 455-2270-ND
N/A Motor, Stepper, 28BNY-48, 5V Online N/A
*The ULN2003A may also be salvaged from a 28BYJ-48 driver board.


The Receiver Software

The following program code for the SIRC receiver can be downloaded using the button at the bottom of this section.

Note that the code consists of a setup portion (lines 9-13), a main routine (lines 14-24), and two goto options. The main routine causes pinC.3 to look for an SIRC code and to store the code it receives in byte register b4. Then, based on whether the code received was "51" or "52", the code branches to one of two places.

The first goto option (lines 25 through 42) turns the stepper motor clockwise (as viewed from the shaft side of the motor.) The second goto option (lines 43 through 60) turns the motor counter-clockwise. The number stored in byte register b4 determines which option is selected: "51" produces clockwise rotation and "52" produces counter-clockwise rotation. In either case, the motor turns in half steps, which produces smoother movement than full stepping.



  PA-08M2 Receiver Code  

The Transmitter Hardware

In operation, SW1 is pressed to bring pinC.1 of the 08M2 low. Software in the µC causes a pre-programmed SIRC "52" to be output from pinC.2, which flashes LEDs 1 and 2 according to the appropriate SIRC pattern. LED1 transmits 940nm IR signals while LED2 visually confirms to the user that the transmitter is active. SW2 works in an identical way with pinC.4 but sends an SIRC "51" signal.


Click to enlarge



Parts List

The parts for the transmitter are shown in the following table. In addition, you will need assorted wire, solder, a well-regulated 5VDC power supply, and a PICAXE programming cable.


Part Ref. Description Source Item No.
J1 Jack, 3.5mm, 3-Conductor Digi-Key CP1-3533-ND
R1 Resistor, ¼ W, 22kΩ Digi-Key 22KQBK-ND
R2, R3 Resistor, ¼ W, 10kΩ Digi-Key 10KQBK-ND
R4 Resistor, ¼ W, 510Ω Digi-Key 510QBK-ND
R5 Resistor, ¼ W, 33Ω Digi-Key 33QBK-ND
R6 Resistor, ¼ W, 470Ω Digi-Key 470QBK-ND
Q1 Transistor, NPN, 2N3904, TO92 Digi-Key 2N3904FS-ND
U1 Microcontroller, PICAXE 08M2 PICAXE 08M2+
LED1 Diode, Light-emitting, IR, 940nm, T1 3/4, LTE-5228A Digi-Key 160-1062-ND
LED2 Diode, Light-emitting, Blue, T1 Digi-Key MV5B640EL-ND
N/A Breadboard, Solderless, 400 Contacts Digi-Key 377-2094-ND
SW1, SW2 Switch, Tactile, Momentary, Normally Open, SPST, Pushbutton, 2-Pin Online* N/A
*All parts are readily available from a variety of suppliers with the possible exception of SW1 and SW2, which may have to be located via an online search. These are ordinary tactile, momentary, normally open, SPST pushbutton switches, but with only 2 pins on the bottom. Because the pins are on 0.2" centers, they work well in solderless breadboards. See the following photo.



The Transmitter Software

The following program code is for the SIRC transmitter and may be downloaded by using the button at the bottom of this section.

The code is quite straightforward. When the pushbutton switch connected to pinC.1 is pressed, pinC.1 is pulled low which causes an SIRC code for "52" to be output from pinC.2 three times. Likewise, when the pushbutton switch connected to pinC.4 is pushed, pinC.4 is pulled low which causes an SIRC code for "51" to be output from pinC.2 three times. In both cases, a 22-millisecond pause is inserted after the code is sent, which allows each transmission to approximate the 45-millisecond defined length of all SIRC codes. Note that line 12 of the code enables pull-up resistors inside the PICAXE IC for pins C.1 and C.4, thus eliminating the need for external pull-up resistors on those pins.



  PICAXE-08M2 SIRC Transmitter Code  

Transmitting and Receiving

The video demonstrates how easy it is to send SIRC codes from the transmitter to the receiver. Simply power up both circuits and press either SW1 or SW2 on the transmitter. At that point, the blue LED on the transmitter should flicker to indicate that data is being sent via the IR LED. Simultaneously, the blue LED on the receiver should flicker to indicate that data is being received by U2. In addition, the stepper motor connected to the receiver should begin to turn; SW2 causes clockwise rotation while SW1 causes counter-clockwise rotation. The LEDs should continue to flicker and the motor to turn for as long as either switch is pressed.

In the video demonstration, the transmitter is just a few inches away from the receiver. However, the actual operating range should be much greater. With a clear line of sight and the IR LED's domed top pointed directly at the IR receiver, distances of more than 20 yards (18.3 meters) should be attainable indoors. The outdoor range may be somewhat less depending on ambient conditions.



This project has explained the fundamentals of IR (infrared) communication and has presented some of the particulars of SIRC (Sony Infrared Remote Code). It has shown how stepper motors can be used to turn in different directions depending on which of two SIRC codes is received.

Imaginative readers can seek additional information about how more-complex IR remote systems work and how other stepper motors could be employed. They might visualize applications for IR remote control of other electrical and electromechanical devices. Hopefully, they can devise uses for IR signaling that have never before been thought of and perhaps build and implement systems that incorporate this functionality.

Are you an imaginative reader?