Go Down

Topic: PORTC (Read 1 time) previous topic - next topic


Oct 11, 2007, 03:02 pm Last Edit: Oct 11, 2007, 03:02 pm by paulb Reason: 1
Is there any way in the Arduino language to access the analog pins as digital pins, or does this require using AVR calls. (e.g. DDRC =oxFF)  ?

Is this documented anywhere except in the Port Maniuplation docs? I poked around a bit and didn't see it.

Is there any reason why the analog pins couldn't be defined somehow to allow pinMode and digitalWrite to work with them.
Either as 14 through 19 or maybe ANALOG0, ANALOG1  etc.

I realize there is an interest in extending Arduino to other chips, so some thought would be in order to make the names generic enough.



I like this idea.  Mostly I was just wondering what to call them: ANALOG0, A0, AI0, ANALOGINPUT0, ANALOG_INPUT0...  Any preferences anyone?

At the moment, you can actually pass numbers 14 to 19 to the digital i/o functions, but I don't want to document the feature until we come up with the final names for the pins.


Oct 11, 2007, 07:19 pm Last Edit: Oct 11, 2007, 07:24 pm by paulb Reason: 1
I like the idea of undocumented features. It's the Arduino way. Sorry about the sarcasm - it's only Mild sarcasm.

I thought A0, A1 were already defined as 0, 1, etc from maybe Wiring port variables - A0, A1 etc seems like the easiest thing, but something to avoid because of future compatibility with other chips (when Arduino becomes truly open-source and takes over the world) oops sorry about that. Been talking to chief heretic Jolliffe too much.

I'd vote for ANALOG0 etc. It is a big differentiation between the digital pins. ANALOGINPUT0 generates cognitive dissonance when the pin isn't an input anymore.

When can I write the docs. Thousands of inquiring minds (OK at least 10) want to know. Also if the pins are already defined as 14-19, shouldn't that be in the docs so people can try and figure out why their project goes haywire when they put a variable in the digitalWrite param and it gets out of range?

Or should 14-19 defs go away when the other scheme gets implemented?

Do you know if PORTC has pullups?  These could get in the way of some high-impedance analog circuits one could imagine.



Datasheet ATmega48/88/168
Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit)


Aren't the port variables PA0, PA1, etc?  Or am I misremembering?  In that case, we could use A0, A1, etc.


My $00.02: I like A0, A1... just because thats the notation Ive been using on my own pcbs. Plus its less to type! I would just be concerned about future compatibility as Im still holding out on the day we can have some form of the arduino mojo on an ATTiny...



What do the ATtiny's use A0, etc. for?

Go Up