interface with the push buttons on a TV

I am trying to put an arduino in between the buttons on the front panel of a tv and the tv.

I have three push buttons, which I want to use to control the TV, I want to use them in a location other than that of the front panel of the tv, they work fine when just soldered to the legs of the orginal push buttons, they are push to ground orignally, momentary buttons,

I have an arduino UNO set up, with a lot of other wires which I plan to use for other things in the future,
For example I have a 4x relay board connected to turn led strips on and off.

I have done a similar thing in the past to control a camera and it posed no problem

what I am currently experiencing is that the power button turns the tv off, but then the tv turns back on straight away, the vol + button is the only one currently also connected during testing, and it does nothing.

all three push buttons at the remote location fucntion as expected in the serial print output, changing from a 1 to 0 when pressed.

all three trigger the light output during the 200ms expected.

My concern is that there is a problem because the TV is a US model, and not grounded, I have it on a transformer, but there is votlage present on all metal surfaces of it, including the ground pins.

If I use the DMM between its ground and earth it registers 150VAC, im not sure if this is normal, logic states not.

my code is as follows.

int up = 5;
int power = 4;
int down = 6;
int uppress = 0;
int uppressprev = 0;
int powerpress = 0;
int powerpressprev = 0;
int downpress = 0;
int downpressprev = 0;


int pi = A2;

int lightson = 0;
int out1 = 7;
int out2 = 8;
int out3 = 9;
int out4 = 10;

int voldown = 12;
int volup = 2;
int menu = A4;
int chdown = A5;
int chup = A3;
int tvpwr = 3;

int tvpwrbutton = 0;
int volupbutton = 0;
int voldownbutton = 0;
int chupbutton = 0;
int chdownbutton = 0;

int state = LOW;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

long Time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers




void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);

  // relay outputs
  pinMode(out1, OUTPUT);
  digitalWrite(out1, HIGH);
  pinMode(out2, OUTPUT);
  digitalWrite(out2, HIGH);
  pinMode(out3, OUTPUT);
  digitalWrite(out3, HIGH);
  pinMode(out4, OUTPUT);
  digitalWrite(out4, HIGH);

  //buttons on front panel
  pinMode(power, INPUT_PULLUP);
  //digitalWrite(power,HIGH);
  pinMode(up, INPUT_PULLUP);
  //digitalWrite(up,HIGH);
  pinMode(down, INPUT_PULLUP);
  //digitalWrite(down,HIGH);

  //original TV inputs
  pinMode(tvpwr, OUTPUT);
  digitalWrite(tvpwr, HIGH);
  pinMode(voldown, OUTPUT);
  digitalWrite(voldown, HIGH);
  pinMode(volup, OUTPUT);
  digitalWrite(volup, HIGH);
  pinMode(menu, OUTPUT);
  digitalWrite(menu, HIGH);
  pinMode(chdown, OUTPUT);
  digitalWrite(chdown, HIGH);
  pinMode(chup, OUTPUT);
  digitalWrite(chup, HIGH);


}

void loop() {

  Read();
  process();

  Tv();
  Lights();
  Pi();


}
void process() {

  if (uppress == LOW && uppressprev == HIGH && millis() - Time > debounce) {

    volupbutton = 1;
  }

  if (downpress == LOW && downpressprev == HIGH && millis() - Time > debounce) {

    voldownbutton = 1;

  }

  if (powerpress == LOW && powerpressprev == HIGH && millis() - Time > debounce) {

    tvpwrbutton = 1;
  }


  powerpressprev = powerpress;
  uppressprev = uppress;
  downpressprev = downpress;
}


void Pi() {

}
void Tv() {

  if (tvpwrbutton == 1) {
    digitalWrite(tvpwr, LOW);
    delay(100);
    digitalWrite(tvpwr, HIGH);
    tvpwrbutton = 0;
    lightson = 1;
  }
  if (volupbutton == 1) {
    digitalWrite(volup, LOW);
    delay(100);
    digitalWrite(volup, HIGH);
    volupbutton = 0;
    lightson = 1;
  }
  if (voldownbutton == 1) {
    digitalWrite(voldown, LOW);
    delay(100);
    digitalWrite(voldown, HIGH);
    voldownbutton = 0;
    lightson = 1;
  }
}
void Lights() {


  if (lightson == 1) {

    digitalWrite(out3, 0);
    digitalWrite(out4, 0);
    digitalWrite(out1, 0);
    delay(200);
    lightson = 0;
  }
  if (lightson == 0) {
    digitalWrite(out3, 1);
    digitalWrite(out4, 1);
    digitalWrite(out1, 1);
  }

}




void Read() {


  uppress = digitalRead(up);
  downpress = digitalRead(down);
  powerpress = digitalRead(power);
  // Serial.println(uppress);
  // Serial.println(downpress);
  //  Serial.println(powerpress);
  delay(20);


}

what I am currently experiencing is that the power button turns the tv off, but then the tv turns back on straight away, the vol + button is the only one currently also connected during testing, and it does nothing.

It could be contact bounce or a timing issue. ...I did something like that once, but there was an LED associated with the button and I used that (the electrical connection to the LED) for feedback to insure the correct state. I don't exactly remember the details, but there was no microprocessor involved.

My concern is that there is a problem because the TV is a US model, and not grounded, I have it on a transformer, but there is votlage present on all metal surfaces of it, including the ground pins.

That's not normal. If you are using a regular isolation transformer (not an [u]autotransformer[/u]) it's probably just low-current leakage. Try sticking a ~100k resistor between the TV chassis and earth ground to see if the voltage drops. If it doesn't drop, that's a concern! If it does drop, it's probably a good idea to ground the chassis. (Grounding it with "real power" on the chassis night blow a circuit breaker, or something "worse".)

If I use the DMM between its ground and earth it registers 150VAC, im not sure if this is normal, logic states not.

its interesting that you mention timing, I had a sketch working that I hadnt saved, maybe I left a different time for the LOW pulse.

I did have it working, just all three of my input buttons working the power button on the TV,

the voltage on the chassis is enough to give a good shock, not one of those types of shocks that makes every joint in your body vibrate and make you wish you hadnt touched that heatsink! but a shock thats enough to make you shout naughty words.

I will have a go at grounding it and see what happens,

I have also thought that it may be easier to use the remote for the tv, and wire the arduino into that,

Maybe use opto couplers between Arduino and TV.
Opto transistor across TV button (emitter tot ground side).
Opto LED (with 1k current limiting resistor) to an Arduino output.
Leo..