I know that ANALOG PINS cans be used for DIGITAL WRITING.. I've read this topic on arduino's website :
I just wanted to know whether ANALOG PINS can be used for DIGITAL READING?
This topic might seem irrelevant to the Section, but i'm trying to read my SENSOR(s) digitally through Analog Pins.. So that Digital Pins can be used for other purposes.
Thank You.
P.S. : I have a Freeduino Board with Atmega8L controller.
On Arduino platform, a definite yes.... Just refer to the pins as A0, A1... etc in the digitalRead()/digitalWrite() function n instead of 1,2... that you would use for digital pins. Whether Freeduino supports this is something you can find out either experimentally or through its documentation
Details and Caveats :
The analogRead command will not work correctly if a pin has been previously set to an output, so if this is the case, set it back to an input before using analogRead. Similarly if the pin has been set to HIGH as an output, the pullup resistor will be set, when switched back to an input.
well, my understanding is, these precautions mainly apply if you're flipping between analog and digital modes within the same sketch - which is fairly unlikely in most practical circuits you would build on arduino. The precaution is you need to set the pin low before swirching to input mode for analogRead to avoid switching on the ATMEGA328s internal pullup resistors. i have never found this t an issue when doing purely digital reads on the pin in the normal way you would read say a switch.
Caveat of course is this applies to the standard Arduino platform.
It's just warning you that if you use the analog pins for digital purposes and later want to use them as analog, you'll need to configure them correctly. But as noted above, you're unlikely to be doing that in a sketch, so go ahead.
FYI, if your board features a Atmel 328p in a TQFP package, there are two additional analog pins (A6 and A7) that are analog only. I doubt you'd ever encounter these on a official board though.