analog/digital

Hello,

Can someone tell me the diference between the analog and the digital pins?

thanks in advantage

Both can be used for digital I/O, but only the analogue pins can be used for analogue input.

A digital pin when read returns a 0 or 1 (LOW HIGH) to indicate 0V and 5 Volt (approx.)

An analog pin when read returns a value between 0 and 1023 (UNO/MEGA) that represents 0..5 volt.

e.g. a value of 255 means a voltage of ~1.25 Volt.

Note that all the analogue pins, can be used as not only analogue inputs but also as digital inputs or outputs. Just address them correctly. On a Uno this is pin 14 for A0 to Pin 19 for A5.

Also note there are no analogue outputs but 6 of the digital pins can be used as PWM outputs which if you apply a filter approximates to an analogue output. These pins are marked with a ~ symbol.

For exactly what PWM is see:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

Analog pins can be used as digital pins using A0 to A5 as well.

Technically, all the pins are digital since you are dealing with discrete values.

The pins labeled "digital" have only two states (high and low) for both inputs and outputs. "Analog" input pins can be converted internally by an ADC (analog to digital converter) to represent one of 1024 discrete values. "Analog" output pins have only two values (high and low) but you can set an output value so that the output average is one of 1024 discrete values.

thank's everyone, it helped me a lot