Control PC power with arduino

bedek:

MichaelMeissner:
I believe the UNO just uses whatever power source has a higher voltage and switches automatically.

But is it going to be quick enough so it will not reset accidentally while switching between sources ?
(I will test it anyway in few days when I will get my arduino)

I just did it, switching from 9 volts via wall wart to USB and back. As long as one of the two power supplies are providing power, it will not reset. According to Nick Gammon's page on the Uno R3, it will automatically switch to the external power if the external power has at least 6.6 volts (at least 7 volts are recommended so that the Uno can deliver 5 volts to its pins): Gammon Forum : Electronics : Microprocessors : Arduino Uno Rev3 pinouts photo

bedek:
Thnx, I'm total noob in electronics I suppose that the easiest thing you be just use another relay which will be set to ON state when the power adapter is on and I will just read state of the relay using one of arduino PINs ?

You probably don't want a relay, since those are fairly slow acting, but an optocoupler is essentially a relay.

bedek:
I would like to use Arduino connected to USB in Linux machine so as far as I understand setting correct serial port using following command should block reset functionality of Arduino:
stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
from: Arduino Playground - LinuxTTY

It has been awhile since I've had to deal with Linux stty, but that looks reasonably correct. Other ways to do it include a custom cable that doesn't pass the reset signal or to use software serial on different ports.