   pinMode(2, OUTPUT); // GND for IR
   digitalWrite(2, LOW);
   
+}
+
+void tv_input_to_blank(){
+  irsend.sendNEC(tv_input, 32);
+  delay(3000);
+  for ( int i = 0 ; i < ( tv_move_input_no - tv_cur_input_no) ; i++ ) {
+    irsend.sendNEC(tv_right, 32);
+    delay(300);
+  }
+  irsend.sendNEC(tv_enter, 32);
+}
+
+void tv_input_to_cur(){
+  irsend.sendNEC(tv_input, 32);
+  delay(3000);
+  for ( int i = 0 ; i < ( tv_move_input_no - tv_cur_input_no) ; i++ ) {
+    irsend.sendNEC(tv_left, 32);
+    delay(300);
+  }
+  irsend.sendNEC(tv_enter, 32);
 }
 
 long check_distance() {

Average<float> ave(5);

int power_status = 1 ;

void setup() {
  Serial.begin (38400);

  Serial.println(int(ave.stddev()));

  if ( ( ave.stddev() < 10) && ( int(ave.mean()) <= 60 )  && ( power_status == 1) ) {
    Serial.println("to blank ch");
    tv_input_to_blank();
    delay(50);
    power_status = 0;
  }

  if ( ( ave.stddev() < 10) && ( int(ave.mean()) > 100 )  && ( power_status == 0) ) {
    Serial.println("to cur ch");
    tv_input_to_cur();
    delay(50);
    power_status = 1;
  }
