arduino to pc detection


im looking for a way to have my arduino uno detect when its connected to a pc because i'm working on a project and i need the arduino to detect automatically when its connected to a pc or not.

When you connect an Arduino to a computer it will reset. So in the start up function send a byte out and wait for the computer to echo it, if it has not done this within a certain time then ther is no computer. The computer has to know to echo a byte received.

To follow from what @Grumpy_Mike has said, you need a program running on the PC that listens for the Arduino and sends a reply when the Arduino sends a message.

This Python - Arduino demo may give you some ideas.