Help With my first project?

This is my first project with arduino. I am fairly familiar with if statements and variables and such from two and a half years of working with tasker for android. My first project with arduino was to control my TV using the arduino xbee and tasker. I have the basics figured out but, I hit a hickup. When I try for just power on and off or just channel up or down ect. I have no issues but when I put them all together in the code I get stuck with the IR LED on and never shutting off? Here is an example of the code I am using... Any help as to what I did wrong would be appriciated.

// See the full tutorial at Sensor tutorials - IR remote receiver/decoder tutorial
// this code is public domain, please enjoy!

int IRledPin = 13;

void setup() {

Serial.begin(9600);
pinMode(IRledPin, OUTPUT);
Serial.println("Ready");

}

void loop()
{
delay(10);
OnOffCode();
if (Serial.available() > 0)
{
int data = Serial.read(); // read the incoming byte:
switch(data)
{
case 'a' : Serial.println("On/Off"); OnOffCode(); break;
case 's' : Serial.println("Channel Up"); ProgramPlusCode(); break;
case 'd' : Serial.println("Channel Down"); ProgramMinusCode(); break;
case 'f' : Serial.println("Volume Up"); VolumePlusCode(); break;
case 'g' : Serial.println("Volume Down"); VolumeMinusCode(); break;
case 'h' : Serial.println("Mute"); MuteCode(); break;
default : Serial.println("Invalid character"); break;
}

}
}

void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait

cli(); // this turns off any background interrupts

while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working

// so 26 microseconds altogether
microsecs -= 26;
}

sei(); // this turns them back on
}

void OnOffCode() {

delayMicroseconds(34496);
pulseIR(880);
delayMicroseconds(860);
pulseIR(880);
delayMicroseconds(840);
pulseIR(1780);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(860);
pulseIR(880);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(1720);
pulseIR(900);
delayMicroseconds(840);
pulseIR(1780);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(23464);
pulseIR(900);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(860);
pulseIR(1760);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(860);
pulseIR(880);
delayMicroseconds(860);
pulseIR(880);
delayMicroseconds(860);
pulseIR(880);
delayMicroseconds(860);
pulseIR(880);
delayMicroseconds(1720);
pulseIR(880);
delayMicroseconds(860);
pulseIR(1780);
delayMicroseconds(820);
pulseIR(880);
}

void ProgramPlusCode() {
delayMicroseconds(44020);
pulseIR(900);
delayMicroseconds(840);
pulseIR(1760);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(860);
pulseIR(920);
delayMicroseconds(820);
pulseIR(880);
delayMicroseconds(860);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(1700);
pulseIR(1780);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(840);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(23424);
pulseIR(920);
delayMicroseconds(840);
pulseIR(1800);
delayMicroseconds(800);
pulseIR(900);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(860);
pulseIR(900);
delayMicroseconds(820);
pulseIR(880);
delayMicroseconds(1740);
pulseIR(1800);
delayMicroseconds(800);
pulseIR(920);
delayMicroseconds(820);
pulseIR(880);
delayMicroseconds(860);
pulseIR(900);
}

void ProgramMinusCode() {
delayMicroseconds(6692);
pulseIR(920);
delayMicroseconds(820);
pulseIR(880);
delayMicroseconds(860);
pulseIR(1760);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(860);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(1720);
pulseIR(1800);
delayMicroseconds(800);
pulseIR(900);
delayMicroseconds(840);
pulseIR(920);
delayMicroseconds(820);
pulseIR(880);
delayMicroseconds(1720);
pulseIR(920);
delayMicroseconds(22584);
pulseIR(920);
delayMicroseconds(820);
pulseIR(880);
delayMicroseconds(860);
pulseIR(1780);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(880);
delayMicroseconds(860);
pulseIR(920);
delayMicroseconds(1680);
pulseIR(1780);
delayMicroseconds(840);
pulseIR(880);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(920);
delayMicroseconds(1700);
pulseIR(880);
}

void VolumePlusCode() {
delayMicroseconds(57164);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(1800);
delayMicroseconds(800);
pulseIR(920);
delayMicroseconds(820);
pulseIR(9200);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(840);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(1700);
pulseIR(1800);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(23444);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(1800);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(1680);
pulseIR(1820);
delayMicroseconds(800);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
}

void VolumeMinusCode() {
delayMicroseconds(22168);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(840);
pulseIR(1800);
delayMicroseconds(800);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(1700);
pulseIR(1800);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(1700);
pulseIR(900);
delayMicroseconds(22584);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(1800);
delayMicroseconds(800);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(840);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(1700);
pulseIR(1800);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(1700);
pulseIR(900);
}

void MuteCode() {
delayMicroseconds(21172);
pulseIR(900);
delayMicroseconds(820);
pulseIR(1800);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(1700);
pulseIR(920);
delayMicroseconds(820);
pulseIR(1780);
delayMicroseconds(1700);
pulseIR(900);
delayMicroseconds(22584);
pulseIR(920);
delayMicroseconds(820);
pulseIR(1800);
delayMicroseconds(800);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(820);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(820);
pulseIR(920);
delayMicroseconds(1700);
pulseIR(900);
delayMicroseconds(840);
pulseIR(1800);
delayMicroseconds(1660);
pulseIR(900);
}

It would help considerably in reading and understanding your code if you put it in code tags having Auto Formatted it and removed superfluous blank lines as suggested in the the sticky at the top of this forum.

I have not looked at your code in detail but the first thing that I noticed was the clumsy way in which the IR pulses are generated with many, many lines of similar code. Why not put the values in arrays and iterate through them with a for loop ? If nothing else it would make the program easier to read.

Hmm... you are using the IRreciever library, right?

If so,

  1. You could use a much,much easier method to pulse the IR. Just calibrate it, store it in a variable and pulse it out on the pin of the IR led.

2)What do you mean by 'combining all of them in the code':

2a) If you mean using two buttons, well, you IR led IS busted.
2b) If you mean just using them in the code, it's possible that two functions are being called at the same time. I didn't pay attention to it because the pulsing is very clumsy.

If not,

1)Same thing as 2 above.