One serial port with two devices?

Hi All!

I'm building a MIDI device and I'd like to make a solution to use the Arduino Nano's serial port for programming AND send/recieve MIDI messages (but not in the same time). I've ran out of free pins, so software serial can't work, and I don't want to use a switch for this purpose, but I thought it could be possible to build a logical gate for the stuff. Do you think it's resoluble? Which gate do I need, OR or NOR? Any experiences with this idea?

Thanks!

tykhaytschaar: Hi All!

I'm building a MIDI device and I'd like to make a solution to use the Arduino Nano's serial port for programming AND send/recieve MIDI messages (but not in the same time). I've ran out of free pins, so software serial can't work, and I don't want to use a switch for this purpose, but I thought it could be possible to build a logical gate for the stuff. Do you think it's resoluble? Which gate do I need, OR or NOR? Any experiences with this idea?

Thanks!

I think your best bet is to use a double pole double throw switch for the job, but that's just my opinion (HIGHLY recommended).

The much more difficult route would be to use TRI-STATE BUFFERS that go high-Z when the PC starts to upload code. How you can tell when the PC is trying to flash the board via a single digital input will be quite interesting if you can get it to work.

The problem is that the IDLE state for a serial line is HIGH. If you connect an external device to the Arduino's Rx pin it will pull it HIGH and that's why the programming won't work - because it will be trying to pull it LOW to send data.

You need some means to disconnect your external device from the Arduino Rx when uploading a program. A switch seems much the simplest.

If you use a logic chip you need something to cause it to change state - a switch? And you need a logic chip that will present a high-impedance to the Rx pin when uploading a program.

You can connect two external serial devices to a single Arduino Rx pin by using a pullup resistor (perhaps 4k7) to cause the HIGH and isolating the devices from the Rx pin with diodes. That allows the external devices to pul the Rx pin LOW, but not HIGH. I don't know if that would be sufficient to allow uploading a program - but it might be worth trying.

...R

There is a simple solution. Unplug the tx / rx pin while downloading and then pug them in. (that's what it do)

I am not sure that logic gate are fast enough (correct me if i am wrong). If logic gates would work than you should use an AND gate. They can be used like switches, one pin is like the lever and the other is the signal.

A regular AND gate does not have a high-impedance option - its ouputs are either HIGH or LOW.

Logic gates are very fast - much faster than an Atmega 328.

…R