Digital Pin 0 and 1 (RX, TX)

I was trying ASCIITable for my arduino construction where I connected some buttons to digital pin 0 and 1 (since I need many pins :slight_smile: )
When they are plugged in the ascii output is quite a mess.
I set the pins to input since the buttons should enable them but did I forgot something? Does this work this way?
Since when I pull connection from 0 and 1 the ascii table is transmitted clean.
The docs say these ports can be used for rx/tx com, but not that they must. Or am I wrong?

The docs say these ports can be used for rx/tx com

What docs are you referring to? The digital pins 0 and 1 ARE used for serial communication. As long as you aren't doing serial communication (including uploading sketches), you can use them for other purposes. That doesn't sound like it's true for you, though.

once you use Serial.begin those pins are dedicated to tx/rx. It sounds like you're sending data back to the PC - right? Then you would need those pins for that.

Just a thought but were you aware that you could use the analog input pins for digital i/o?

1 Like

It is strange that the two pins are advertised as digital pins but are in fact only for serial communication.

And I did not know that I could use Analog pins for that since I assumed (did not check that) that they dont have a low and high but are in the discrete 0..1 interval

It is strange that the two pins are advertised as digital pins but are in fact only for serial communication.

Serial communication IS digital input / output. As pointed out you can use them but you loose the ability to communicate and up load sketches.

The analogue pins are for analogue input only not analogue output. You can use them like any other pin by referring to them as pins 14 to 18. They can be a digital input or a digital output.

Could you clarify a little?

I too was wondering about using these pins. Are you saying that if I hook anything up to the pins I will no longer be able to upload sketches? As in, pressing the reset button, and then clicking upload won't work anymore, even though the code already on the arduino isn't yet running and shouldn't have had a chance to set them to be outputs?

Why is that? Is it because whatever I hook up to the pins will interfere electrically with the signal?

Kind of depends exactly what you're doing with the digital pins beside using them for serial communications. If you're blinking LEDS with them it isn't going to be a problem, if its a lowish impedance circuit it will be a problem, of course your sketch will need to allow for it if you're using it for serial communication within the sketch

if its a lowish impedance circuit it will be a problem.

Exactly the opposite, a high impedance load is no problem but a low impedance load will distort the signals coming in / out to / from the serial / USB chip.

Exactly the opposite, a high impedance load is no problem but a low impedance load will distort the signals coming in / out to / from the serial / USB chip.

Errmm, isn't that what I said ? :slight_smile:

Extrema apologias, yes that is what you said. :-[

In my defence I do have a cold at the moment.

Don't worry about it GM :slight_smile:

If an LED is okay, how about an array of them?

What I need to do is run a piezo speaker and four 20 segment bargraphs. I would like to hook the piezo up to one of the analog pins so I can do PWM, and use 18 more pins to drive the four bargraphs as set of eight in a 10x8 led array.

I would also like to hook a switch up so I can change the display mode.

That requires exactly 20 pins, which I have, IF I can make use of those serial pins without screwing up my ability to upload sketches.

So let's say Digital Pin 0 and 1 were each connected to the anodes of 8 leds, and the cathodes of those leds were connected to pins 10 thru A3 via some 82 or 150 ohm resistors.

Would I have any trouble uploading my sketches in that case?

I just looked up impedance, cause I wasn't sure if that was another word for resistance or something else, and I founf out it's resistance to alternating current.

So I guess that is why the leds will work? They're high-impedance because electricity can only flow through them one way?

If that is the case, out of curiosity, could one hook up low impedance stuff, like say, a switch, to those pins, without interfering with uploading sketches, as long as you placed a diode in series with it?

They're high-impedance because electricity can only flow through them one way?

Sorry that's not how it works. A diode would present a low impedance because it would short out half the time and the other half it would be open circuit. In effect the short wins and gives a low impedance.

Here impedance is used to indicate the load on a pin. What you have to consider is that the USB / Serial chip is trying to drive the arduino pin, if you put another load across it there might not be enough power to drive both the arduino and the load you put on the pin.

Good advice is not to mess with those pins unless you know exactly what you are doing. Use a shift register to get your extra outputs. You are also limited to the 200mA maximum output current from all the combined pins of the arduino.

Also, I guess this means that as long as you can disconnect whatever it is you have hooked up to that pin while you're uploading the sketch, you could reconnect it after the sketch is uploaded and everything will work fine? I plan to stick my pro-mini in an IC socket, so it occurs to me that I could simply unplug it if I need to update the sketch.

Or in the future, I could connect things via a socket and just unplug that one component from the board while uploading.

I guess this means that as long as you can disconnect whatever it is you have hooked up to that pin while you're uploading the sketch, you could reconnect it after the sketch is uploaded and everything will work fine?

Yes exactly. That is what I have done here:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Shield.html

Sorry that's not how it works. A diode would present a low impedance because it would short out half the time and the other half it would be open circuit. In effect the short wins and gives a low impedance.

Ah. :frowning:

Here impedance is used to indicate the load on a pin. What you have to consider is that the USB / Serial chip is trying to drive the arduino pin, if you put another load across it there might not be enough power to drive both the arduino and the load you put on the pin.

So what about the circuit I described?

If I have an LED with the anode connected to pin 0, and the cathode connected, via a resistor, to another pin, then as long as that other pin is low, there won't be a load, right? The serial pin may go high and low, but when it's low, no electricity would flow from one pin to the other, and when it's high, the led would prevent the electricity from flowing. Correct?

What state are the pins in when I reset the Arduino though? They are low, aren't they? If they're high, that might be a problem.

What state are the pins in when I reset the Arduino

They default to inputs so they are all high impedance.

Then the boot loader takes over and initialises pins 0 and 1 to use serial communication. So the TX (pin 1) is an output set high and the RX (pin 0) is an input. The Serial / USB chip is connected to these pins through a 1K resistor so it has a limited capacity for pulling pin 0 low if another load is attached to it. Similarly pin 1 is connected through a 1K resistor, if this has a load on it then it might not be able to drive the serial chip to the required voltage levels.

You said earlier that a high impedance load is no problem. And that an LED is such a high impedance load.

But you also indicated that a diode isn't a high impedance load. Or at least, that connecting a diode in series with a low impedance load wouldn't allow you to connect the low impedance load.

Does high impedance mean low resistance?

You also just said the pins are set to an input state which is high impedance. Does that also mean low resistance? I thought the input state was one where they went to ground via a large resistor, which is why you can use that state to charlieplex... because electricity won't flow easily.

But then you said:

Then the boot loader takes over and initialises pins 0 and 1 to use serial communication. So the TX (pin 1) is an output set high and the RX (pin 0) is an input. The Serial / USB chip is connected to these pins through a 1K resistor so it has a limited capacity for pulling pin 0 low if another load is attached to it. Similarly pin 1 is connected through a 1K resistor, if this has a load on it then it might not be able to drive the serial chip to the required voltage levels.

Given that it's been said leds are high impedance, and the pins are high impedance, and that it was said high impedance loads aren't a problem for the serial pins, why does it seem here like you're indicating that the setup I descibed will interfere with uploading the sketches?

I'm totally confused now. :frowning:

Let's start over.

Kind of depends exactly what you're doing with the digital pins beside using them for serial communications. If you're blinking LEDS with them it isn't going to be a problem, if its a lowish impedance circuit it will be a problem, of course your sketch will need to allow for it if you're using it for serial communication within the sketch

a high impedance load is no problem but a low impedance load will distort the signals coming in / out to / from the serial / USB chip.

What state are the pins in when I reset the Arduino?

They default to inputs so they are all high impedance.

Then the boot loader takes over and initialises pins 0 and 1 to use serial communication. So the TX (pin 1) is an output set high and the RX (pin 0) is an input. The Serial / USB chip is connected to these pins through a 1K resistor so it has a limited capacity for pulling pin 0 low if another load is attached to it. Similarly pin 1 is connected through a 1K resistor, if this has a load on it then it might not be able to drive the serial chip to the required voltage levels.

Okay, so I've been reading up on impedance, and what I've read seems to indicate that in general, impedance = resistance. Therefore, high impedance means high resistance.

If that's the case, then I'm guessing that those pins which are set to input, a high impedance state, are going to ground through a large resistor.

And when you say that it's okay to connect a high impedance load to the serial pins, what you mean is that it's okay to connect a load with a lot of resistance.

What I don't get is why that means an led is okay, but something else with a resistor in series is not.

What I also don't get is if it's the voltage that matters to the serial chip, then why is an led okay, but something else with a resistor is not. A resistor to my knowledge doesn't affect voltage levels. An led does.

Lastly, if an led is a high impedance load, and the pins are set to a high impedance state, then that's like twice the impedance. Shouldn't an LED connected (via a resistor) between one of the serial pins, and another pin therefore have no effect on the serial signal when it is off?

What I really need to know is if I can multiplex an array of led's using those serial pins for a couple of the rows without affecting my ability to upload sketches.

I could unplug the arduino to upload a sketch, but I'd rather not stress the chip plugging and unplugging it if I don't have to. I don't even know how easy it will be to get those header pins out of the IC socket once they're in there.