Turning TV On And Off

I am trying to turn my TV on and off using a cloud server. I tried the code below and it works but I would like to integrate a Push button effect. For example, when a specific pin (Pushbutton) is HIGH, the function that turns the tv on and off should come into effect. Does anyone know how this can be done?

int IRledPin = 13;
int Pushbutton = 5;

void setup(void)
{
// Start Serial
Serial.begin(9600);
pinMode (IRledPin, OUTPUT);

}

void loop() {

SendChannelUpCode();

delay (10000);
}

// 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 downstairs TV COMCAST
delayMicroseconds(3568); //Time off (Left Column on serial monitor)
pulseIR(9240); //Time on (Right Column on serial monitor)
delayMicroseconds(4540);
pulseIR(600);
delayMicroseconds(540);
pulseIR(620);
delayMicroseconds(520);
pulseIR(620);
delayMicroseconds(540);
pulseIR(600);
delayMicroseconds(540);
pulseIR(620);
delayMicroseconds(520);
pulseIR(600);
delayMicroseconds(540);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(600);
delayMicroseconds(540);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(1660);
pulseIR(640);
delayMicroseconds(1660);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(600);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(520);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(600);
delayMicroseconds(540);
pulseIR(640);
delayMicroseconds(1660);
pulseIR(600);
delayMicroseconds(540);
pulseIR(620);
delayMicroseconds(520);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(640);
delayMicroseconds(500);
pulseIR(620);
delayMicroseconds(540);
pulseIR(600);
delayMicroseconds(540);
pulseIR(600);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(540);
pulseIR(600);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(520);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(1680);
pulseIR(600);
delayMicroseconds(1680);
pulseIR(620);
delayMicroseconds(40780);
pulseIR(9260);
delayMicroseconds(2240);
pulseIR(620);
delayMicroseconds(32624);
pulseIR(9240);
delayMicroseconds(2260);
pulseIR(600);
delayMicroseconds(32644);
pulseIR(9240);
delayMicroseconds(2260);
pulseIR(620);
delayMicroseconds(32624);
pulseIR(9240);
delayMicroseconds(2260);
pulseIR(600);
delayMicroseconds(32644);
pulseIR(9240);
delayMicroseconds(2260);
pulseIR(600);

}

Welcome to the forum! If you put your code in code tags (</>) it makes it much easier to read..

At its most basic use something like

void setup(void)
{
// Start Serial
Serial.begin(9600);
pinMode (IRledPin, OUTPUT);
pinMode (Pushbutton, INPUT);

}

void loop() {

if (digitalRead(Pushbutton)) {
  SendChannelUpCode();
}
delay (10000); 
}

What effect does if(digitalRead(Pushbutton)) have on the program?

my code above works like the code below but perhaps this is a little easier to follow if you are new to programming.

button_state=digitalRead(Pushbutton); // read the state of the push button 1 or 0/ true or false

if (button_state == 1) {  // if button pressed send the channel code
  SendChannelUpCode();
};

dezelec:
What effect does if(digitalRead(Pushbutton)) have on the program?

You are not willing to make your code readable, I am not willing to help you. Easy.

I figured it out as shown below. Thanks for your initial suggestion.

void loop()                     
{
  if (digitalRead(Pushbutton) == HIGH){
 
  SendChannelUpCode();
  }
  delay(3000);

  
  // Connect to the cloud
  rest.handle(client);

}