how to combine these two codes, help...

hello, Im really new to using arduino, so forgive me if I sound really dumb, but I have these two
programs that I need to combine so that I dont have to use extra arduino. I tested both of the codes individually and they work fine, no problem. Now I need to combine it into one code.

The codes are basically, first one is tvbgone (long code), what it does is send bunch of tv ir codes on pin 3 to shut off any brand tv. The second code (really short) is similar to blink program, it just sends continuous infared pulses high low in microseconds on pin 12 to freeze any tv remote.

Since both codes use same output load ( bunch of ir leds) what I want to do is have both codes run at the same time, and then I can add a switch between pin 3 and pin 12, And depending on switch I decide which code I want to use to turn on my ir leds.

I tried to do it on my own by putting the 2nd code into the tvbgone code, but its not working properly. I want some help like where exactly I should put my 2nd code ( short one below) into the long code so that both codes are putting outputs on pins (3, 12) which i can control with a switch. ?? If there is some other way to do then please tell .

First code is

//This is a Daniyal Shamsi program in which an ir led is placed

//on pin 12 and is kept near tv,and it blocks the tv remote signals...

int irled = 12;

void setup()
pinMode(irled, OUTPUT);

void loop() {

digitalWrite(irled, HIGH);
digitalWrite(irled, LOW);


The 2nd one I have attached.

main.h (1.94 KB)

TVBGone.ino (17.2 KB)

WORLDcodes.cpp (126 KB)


Here is some suggestion on how to approach this: