Arduino State Change Dection and Voltage

Hi All,

Bit of a back story of what i am trying to achieve.

I am building a Vewlix Clone arcade running a computer with HDMI Output and a LED TV for the display.

The Computer doesn’t support CEC so i am looking for a simple/creative way to power on the TV.

The power button on the TV is a momentary push button. I understand the Arduino can detect voltage up to 5V.

What i want to do is use the Arduino to detect voltage on one pin (3.3v) and when detected to momentary press (close) the power button turning on the TV, and when power is lost momentary pressing the button again turning the TV off.

Just wondering if this is possible?

Thanks
Rob

when power is lost momentary pressing the button again turning the TV off.

Which device is losing its power ?
Do you mean that if power is lost with the TV on then restoring it should leave the TV turned off until a button press is received ? If so, then I know that as an NVR switch as used on some power tools

Thanks for the reply, i should have been more clear my apologies.

What I want to do is use the 3.3v from the computers ATX power supply to be monitored by the Arduino.

When the Arduino detects the voltage (High) to momentary close the circuit to power on the TV.

Once the Arduino no longer detects voltage (Low) it will momentary close the the circuit once more to power off the TV.

I hope this can be understood.

Thanks
Rob

What you have described is perfectly possible
What have you tried so far ?

Why not use the pc’s 12v line which is on when the PC is on. Just power a relay off this 12v and use the contacts from that .
No Arduino needed

Thanks for the Replies, I haven't tried anything yet, as i wanted to make sure its feasible.

I thought about the relay path, but usually once power is detected the relay stays on where this only needs to complete the circuit momentarily to do the "button press".

Thanks
Rob

There are many ways to make it momentary in hardware.

A 555 monostable circuit, for example. More reliable and cheaper than an Arduino.

This is what i have come up with, open to suggestions/improvements

const int analogPin = A0;    // ATX Power 5V 
const int relay = 13;       // pin that the relay trigger is attached to
const int threshold = 400;   // threshold level that should be exceeded by the analog input
int A=0;  // value to control the if statements

void setup() {
  // initialize the relay pin as an output:
  pinMode(relay, OUTPUT);
  // initialize serial communications:
  Serial.begin(9600);
}

void loop() {
  // read the value analog input:
  int analogValue = analogRead(analogPin);

  // if the analog value is high, trigger the relay:
  if(A==0){
  if (analogValue > threshold) {
    digitalWrite(relay, HIGH);
    delay (500);
    digitalWrite(relay, LOW);
    A=1;
    delay(10);
    }
  }
 // if the analog value is low, trigger the relay: 
  if(A==1){
  if (analogValue < threshold) {
    digitalWrite(relay, HIGH);
    delay (500);
    digitalWrite(relay, LOW);
    A=0;
    delay(10);
    }
  }
}

Does it work as intended?
If not, what does it do and how is it different from what you want it to do?

Why do you use an analog read for what should be a digital signal? (ATX 5V power line should be always either 5V or 0V, if there's another value it's time for a new power supply).

If i connect 5v to a digital pin and use digitalread, will the value return the voltage, or a 1 or 0?

Thanks
Rob

digitalRead() returns 1 or 0, aka HIGH or LOW.

If you want to know the actual value of the voltage, use analogRead(). For better accuracy and stability, use a voltage divider to bring it down to <1.1V and use the internal reference.