This project is an exploration of Ken Shirriff’s Arduino-IRremote library. My initial goals with this Arduino library were:
- Receive and document the hexadecimal infrared codes corresponding to remote button presses
- Manually transmit infrared codes to activate various device functions
- Use motion detection functionality to trigger device functions
The breadboard image at the top of this post contains three key parts: an output infrared LED (top left), an input pushbutton (center), and an input TSOP382 infrared receiver (right of center). I followed a very helpful SparkFun tutorial as a reference for these experiments; the recommended circuit diagram is copied below:
Goal 1: Receive IR codes
With the circuit assembled, I used the included IRrecvDemo.ino example to capture IR remote transmissions and print to the serial monitor. Below (left) is a sample screenshot of various button presses from my Ambery security switcher’s remote control. I tabulated each button and its corresponding hexadecimal code for future reference, below (right):
Goal 2: Transmit IR codes
After documenting these codes, I then attempted to control the device using the Arduino and IR LED. I tested the IRrecord.ino sketch, which allows the user to capture an IR code with the Arduino and re-transmit it with the IR LED upon pressing the pushbutton. There were some intermittent issues with the button — perhaps the schematic wasn’t current with the example code — but the sketch proved functional! I hunted down the important bits needed to try manually transmitting an IR code: irsend.sendNEC(), which expects an unsigned long data (the hex code) and int nbits (# of bits). I chose the Freeze function, which has a hexadecimal code of 4FBE817, and nbits = 32.
Goal 3: Freeze frame upon motion detection
To transmit the code upon motion detection, I modified my motion detection Arduino sketch to issue a freeze frame command instead of toggling an LED, in addition to printing a status message to the serial monitor. As shown in the video below, when my hand moves out of the masked right-hand side of the video frame, the Arduino transmits a freeze toggle command.
When the motion of my hand is detected in the left side of the frame, a Freeze Frame command is issued via an IR LED.
The sensitivity settings need to be adjusted, or perhaps debounce logic may be helpful in fine-tuning the response of the motion detection. This initial milestone lays the groundwork for a wide array of potential applications. In particular, I am interested in an interactive installation that affects the displayed video upon viewer movement, notably, playback from and recording to a VCR.