PIR controlled IR tv remote

Hi guys, I am working on a project to trigger my tv on using a PIR and IR led. I have code to trigger the remote with a push button switch, but I want to use a PIR. Thanks in advance. Here is my code:

int IRledPin = 13; // LED connected to digital pin 13
const int buttonPin = 10;
int previousButtonState = 0;
int buttonState = 0;

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the IR digital pin as an output:
pinMode(IRledPin, OUTPUT);
pinMode(buttonPin, INPUT);

Serial.begin(9600);
}

void loop()
{
buttonState = digitalRead(buttonPin);
if(buttonState != previousButtonState){
if(buttonState == HIGH){ //Sends the code every time the button is pressed.
SendChannelUpCode();
}
}
previousButtonState = buttonState;
}

// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We’ll use this whenever we need to send codes
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
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds

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

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

void SendChannelUpCode() {
// This is the code for the CHANNEL + for the TV COMCAST

delayMicroseconds(34480); //Time off (LEFT column)
pulseIR(9180); //Time on (RIGHT column) <-------DO NOT MIX THESE UP
delayMicroseconds(4700);
pulseIR(460);
delayMicroseconds(700);
pulseIR(460);
delayMicroseconds(700);
pulseIR(440);
delayMicroseconds(1860);
pulseIR(440);
delayMicroseconds(700);
pulseIR(460);
delayMicroseconds(680);
pulseIR(460);
delayMicroseconds(700);
pulseIR(460);
delayMicroseconds(680);
pulseIR(460);
delayMicroseconds(700);
pulseIR(440);
delayMicroseconds(1840);
pulseIR(460);
delayMicroseconds(1860);
pulseIR(440);
delayMicroseconds(700);
pulseIR(460);
delayMicroseconds(1780);
pulseIR(520);
delayMicroseconds(1840);
pulseIR(460);
delayMicroseconds(1840);
pulseIR(460);
delayMicroseconds(1820);
pulseIR(460);
delayMicroseconds(1840);
pulseIR(460);
delayMicroseconds(700);
pulseIR(460);
delayMicroseconds(680);
pulseIR(460);
delayMicroseconds(660);
pulseIR(480);
delayMicroseconds(1840);
pulseIR(460);
delayMicroseconds(700);
pulseIR(460);
delayMicroseconds(700);
pulseIR(440);
delayMicroseconds(700);
pulseIR(440);
delayMicroseconds(680);
pulseIR(480);
delayMicroseconds(1860);
pulseIR(440);
delayMicroseconds(1820);
pulseIR(480);
delayMicroseconds(1840);
pulseIR(460);
delayMicroseconds(700);
pulseIR(440);
delayMicroseconds(1820);
pulseIR(480);
delayMicroseconds(1840);
pulseIR(460);
delayMicroseconds(1860);
pulseIR(440);
delayMicroseconds(1860);
pulseIR(440);
delayMicroseconds(41360);
pulseIR(9160);
delayMicroseconds(2400);
pulseIR(460);
delayMicroseconds(33364);
pulseIR(9160);
delayMicroseconds(2420);
pulseIR(440);
delayMicroseconds(33344);
pulseIR(9180);
delayMicroseconds(2420);
pulseIR(440);
delayMicroseconds(58560);
pulseIR(100);

}

Please read How to use the forum and edit you post accordingly.

And what did you try? What happened instead? Why not use the IR library to make life easy?

It makes NO difference if the "turn the stupid TV on" call happens because the pin that was read has a physical switch connected to it or a infrared sensor connected to it. The pin is HIGH, is LOW, became HIGH, or became LOW. The Arduino doesn't know, or care, what is connected to the pin.