Can analog pins be used as a digital output pin?

I am using an arduino uno. I would like to know if you could use analog pins as digital pins. Also the digital pins labelled 0 and 1, can it be used as digital pins, i am asking this because its written Tx and Rx near those 2 pins.

thanks

Yes, you can use the analog pins as digital pins D14 through D19.

Digital pins 0 and 1 can be used as digital pins however these pins are used for serial communication to the PC over USB, including downloading sketches from the PC to the Arduino. So if you connect physical devices to pins 0 and 1, they may interfere with the downloading process.

--
The QuadRAM shield: add 512 kilobytes of external RAM to your Arduino Mega/Mega2560

What is the Vin pin for? For example I am using a 9V battery with a jack to power up arduino then, in that case do I have to use Vin?

Also, if I power the arduino Uno with 9V battery and the jack, can I use the 5V regulated pin to power components like LED?

yaantey:
What is the Vin pin for? For example I am using a 9V battery with a jack to power up arduino then, in that case do I have to use Vin?

No, The Vin pin is not needed to be used in that case. Vin pin is just another way to apply the same voltage input range that the external DC power connector provides to power the board. Vin can also be used to supply power for external components wired to the Vin pin provided that you are powering the board via the external DC power connector and not via the USB cable. But just be aware of the voltage range and current capacity avalible from the pin. Also be aware that using a small 9v battery is a poor choice to power your board as they are very expensive Vs that total power capacity they provide.

Lefty

Also, if I power the arduino Uno with 9V battery and the jack, can I use the 5V regulated pin to power components ...

Yes, as long as your components don't use too much current and overload the regulator on the UNO.

... like LED?

You could power an LED from here but that would not be a good choice since LEDs do not need a regulated voltage (or a regulated current). They need a specified amount of current but even large variations in that current (as long as they are within the allowable range) do not produce large changes in the perceived brightness of the LED.

Don

You could power an LED from here but that would not be a good choice since LEDs do not need a regulated voltage (or a regulated current).

Well they need a limited current and normally that depends on a regulated voltage. I would say powering an LED off the +5V rail is a good choice. The alternative, powering it off the Vin, will require you using a transistor so that you don't exceed the maximum voltage on the output.

Well they need a limited current and normally that depends on a regulated voltage. I would say powering an LED off the +5V rail is a good choice. The alternative, powering it off the Vin, will require you using a transistor so that you don't exceed the maximum voltage on the output.

If you want to control the LED by connecting it directly to the Arduino then you have to consider the voltage as you have pointed out.

I guess I took his question ("can I use the 5V regulated pin to power components like LED?") more literally. When it comes to powering an LED I stand by my answer. If you also want to control the LED with the Arduino then using a transistor is a good choice and my answer still holds.

Don