Go Down

Topic: Digital Pin 0 and 1 (RX, TX) (Read 11006 times) previous topic - next topic

Seikilos

I was trying ASCIITable for my arduino construction where I connected some buttons to digital pin 0 and 1 (since I need many pins :) )
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?

PaulS

Quote
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.

bill2009

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?

Seikilos

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

Grumpy_Mike

Quote
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.

scswift

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?

pluggy

#6
Feb 19, 2010, 12:28 pm Last Edit: Feb 19, 2010, 12:32 pm by stephen_t Reason: 1
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
http://pluggy.is-a-geek.com/index.html

Grumpy_Mike

Quote
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.

pluggy

Quote
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  ?  :)
http://pluggy.is-a-geek.com/index.html

Grumpy_Mike

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

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

pluggy

http://pluggy.is-a-geek.com/index.html

scswift

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?

scswift

#12
Feb 19, 2010, 02:09 pm Last Edit: Feb 19, 2010, 02:10 pm by scswift Reason: 1
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?

Grumpy_Mike

#13
Feb 19, 2010, 02:14 pm Last Edit: Feb 19, 2010, 02:16 pm by Grumpy_Mike Reason: 1
Quote
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.

scswift

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.

Go Up