Arduino to turn on PC using Opto-coupler help needed

I’ve messing around with different ways to turn on PC using an Arduino, remotes, RFID, magnets, etc.
That side of the problem is fine, using serial print I can see they do what they are meant to and trigger the correct code :smiley:

My problem currently is I can’t get the other side of it to work properly. (see attachments)
It’s either a code problem or component problem.
I can get this to work to a point but it turns the computer off within a second or so.

My questions are:

  1. Do I need to set pin connected opto-coupler to high or low for the output side to make to connection and turn on my PC?
  2. Is delay(100) enough time?
  3. Do I need a resistor on the output side? If so, how large?
  4. Is there anything I missed or that’s wrong in my schematics?

The schematic (let’s just forget about the other, it’s a Fritzing wire diagram):
27dd7b1e6ca9edd06d127cff3bf7f09c8feecdfe.png

How does this connect to your computer?
Iirc an ATX power supply is triggered by shorting two pins on the motherboard. I assume you connect those two to the appropriate sides (yes, direction matters) of the phototransistor?

You have to make your pin HIGH, so the LED lights, and the phototransistor starts to conduct. That should trigger the power supply. After that set it LOW again, keeping it on for too long (i.e. power button pressed for 4-6 seconds) and the PC will switch off.

What kind of button is the power button on your PC, and where are you intercepting it? Do you also have a reset button or does the power button also serve as reset based on duration held? You need to know these things and share that info.

Sorry, the front panel switch, momentary switch, connects directly to front panel headers on the motherboard.

Assuming you have wired your optocoupler the correct way, I don't see why it wouldn't work.

Use a multimeter to connect the two wires, check which side is positive, which side negative. Then you know which way to wire your optocoupler.

Use the multimeter to check whether the optocoupler is really on when you think it's on (set the Arduino pin HIGH, and measure the resistance - it should be low).

Try switching on your PC using a small resistor, 100-500 Ohm, to simulate the phototransistor in ON state, and tapping it to the pins you want to connect your optocoupler to.

If that works, try it again, now hold the resistor against the pins, see what happens (I expect it to switch off again after a few seconds).

Another thing, why would you use the TX pin of the Arduino, and not one of the normal digital pins?

wvmarle:
Another thing, why would you use the TX pin of the Arduino, and not one of the normal digital pins?

I assumed all pins were made the same, well the digital ones anyway. I just chose a pin close to my board.

I was running a test with an LED after the Opto-coupler and it was always staying on regardless of how I set Digital Pin 1.
So I swapped for pin 7 and now it works, pin 1 for some reason didn't want to accept that it was either high or low.

Next step is to convert this little marvel to an ATMEGA328P chip I have on the way and use it as the main way to turn on my PC.

Thank you for all the help.

Wonder if your sketch had a Serial.begin anywhere in it.

INTP:
Wonder if your sketch had a Serial.begin anywhere in it.

It does, doesn't need to anymore as I won't be seeing the output.
Didn't realise that pins 0 and 1 are also linked to the serial output, only had it about 2 weeks.

CuriousGamer:
It does, doesn't need to anymore as I won't be seeing the output.
Didn't realise that pins 0 and 1 are also linked to the serial output, only had it about 2 weeks.

Yeah, the TX and RX labels next to them are trying to tell you something.

It's also the ports that are used to program the thing so you may end up interfering with that, and suddenly programming doesn't work.