Instructables

Step 4: Test Your Remote

Picture of Test Your Remote
At this point we're going to change the Breadboard on your Arduino to the tactile switch/IR LED setup pictured below.  You'll also need to download my PrankChannelTests sketch linked below. 

Work to do on your sketch:
Replace my channel pulse codes with your pulse codes.  Copy/Paste your cleaned up codes from the previous step to replace the codes I used.  They go between your "{" and "}" brackets.
Also the code is set up to only work for numbers that are actual channels on my TV.  To change this in your sketch you need to modify two pieces of the code.
First is the line just above Serial.println(channel);  You only want a "|| channel == 4" for channels you want printed in your Serial Monitor.
Second is the switch/case;  You only want a
" case 4:
irsend.sendRaw(channel4,68,38);
break;"
for channels you want the IR LED to change your TV to.

Work to do on your Breadboard:
Set up the breadboard exactly as it's shown in the picture:
The left side of the tactile switch goes to Arduino 5V
The right side of the tactile switch goes to Arduino digital pin2 and a 10K Ohm resistor
The other end of the 10K Ohm resistor goes to Arduino Gnd
Arduino pin3(PWM) goes to a 15 Ohm resistor
The other end of the resistor goes to the Anode(+) (longer lead) of the IR LED
The other end of the IR LED, the Cathode(-) (short lead), goes to Arduino Gnd

As a note; my picture shows me using a 15 Ohm, 1/2Watt resistor to limit my infrared LED.  You're supposed to use a 100 Ohm 1/4Watt resistor.  I tried that but only got about 5 feet of range with my remote, so I swapped out the 100 Ohm resistor for 5, 15 Ohm resistors in series (75 Ohm total).  That gave me a little more range, so I decided to slowly remove one 15 Ohm resistor at a time until I had whittled it down to just one 15 Ohm, 1/2Watt resistor.  I'm pretty sure this isn't the best way to treat the IR LED, but it worked so I stuck with it.  I cracked open a real remote control and they used a teeny SMT transistor but I couldn't figure out the schematic they used.  With the one 15 Ohm resistor I ended up with 25-ish feet of range.  So take this as a warning NOT TO BURN UP YOUR IR LED!  This is how I did it, but if you're uncomfortable with this then play it safe and stick with the 100 Ohm, 1/4Watt resistor.

Test it:
With your breadboard modified and your new sketch fixed up with your cleaned up pulses we're ready to test it out.  Plug in your Arduino, upload your sketch and then open the Serial Monitor.
Now when you push the button it'll send signal HIGH to digital pin2 (our trigger pin) which will then display your random channel in your Serial Monitor, delay one second and then flash your pulses to the IR LED, changing your TV channel.  If everything's working, as it should be, then all that's left is to swap out the tactile switch with the CH4 Methane sensor and encase it.