Author Options:

Arduino Analog Pin? Answered

Can a arduino analog pin be used as a output pin?

4 Replies

blinkyblinky (author)2012-05-18

I think the results should be read through the analog pins.

The output to the LED should be utilizing the digital pin because after some extensive (as well as late-at night) testing I realized Analog pins can NOT handle the 'analogWrite' function. You would need to manually do it so you should stick to utilizing the digital pins.

Select as Best AnswerUndo Best Answer

buteman (author)2012-02-11

Yes, it can but not a steady value as such. 

For example:
int pin = 0 ;//analogue pin 0
int value;

void setup(){} // nothing to do in setup

 void loop()
value needs to be between 0 and 255
if value is 0 the output is 0 volts, if value is 255 the output is 5volts.
if value is between 1 and 254 then the output is a PWM stream.
That is the value varies rapidly between 0 and 5 volts with the output being high and low each of which depends on what 'value' is set to.
If value is 64 then the output will be 5 volts for a quarter of the time and 0 volts for three quarters of the time.

Select as Best AnswerUndo Best Answer

txrx (author)2012-02-10

Sure can! see documentation for the digitalWrite() function

http://arduino.cc/en/Reference/digitalWrite According to that doc "The analog input pins can be used as digital pins, referred to as A0, A1, etc."

Select as Best AnswerUndo Best Answer

Bot1398 (author)txrx2012-02-10

But if I want to use it for a sensor application and as a output too for eg i want to make a rgb color sensor and I want the same color sensor to output what it has detected is it possible

Select as Best AnswerUndo Best Answer