Two Arduinos with one USB 2 lead.

I've two Arduinos (Arduini?), a Uno and a Mega, in a case which originally contained a SCSI CD drive, so it has a PSU (12V and 5V). Both have their Vins and their Grounds connected to the PSU 5V output. I want to program them (one at a time) with the same USB lead.

Do I need a DPDT switch on just the D+ and D- lines to switch between them?
Or, if all four USB lines are connected to both, will the IDE detect the correct Arduino if I select (in the IDE), say, the Uno to upload to?
That seems unlikely.

Henry_Best:
Do I need a DPDT switch on just the D+ and D- lines to switch between them?

Yes.

Henry_Best:
Or, if all four USB lines are connected to both, will the IDE detect the correct Arduino if I select (in the IDE), say, the Uno to upload to?

No. You can't have two devices trying to drive a piece of wire simultaneously.

fungus:

Henry_Best:
Do I need a DPDT switch on just the D+ and D- lines to switch between them?

Yes.

Done that. Thanks.

Henry_Best:
Or, if all four USB lines are connected to both, will the IDE detect the correct Arduino if I select (in the IDE), say, the Uno to upload to?

No. You can't have two devices trying to drive a piece of wire simultaneously.

That's not quite what I meant. If I tell the IDE to upload to the Mega (in Boards), will it ignore the Uno and just upload to the Mega and vice versa? As I said, it seems unlikely. But I've put in a DPDT switch now and I'll test it tomorrow, after I've reassembled the box.

Henry_Best:
No. You can't have two devices trying to drive a piece of wire simultaneously.

That's not quite what I meant. If I tell the IDE to upload to the Mega (in Boards), will it ignore the Uno and just upload to the Mega and vice versa? As I said, it seems unlikely. But I've put in a DPDT switch now and I'll test it tomorrow, after I've reassembled the box.
[/quote]

It might pop up some annoying dialogs about serial ports or something, I haven't tried it.

OTOH you could open two separate IDEs and switch between them when you throw your switch. That will probably work better.

This raises a question: Why do you need to use a single USB cable? Why not two?