3780Views4Replies

Author Options:

Arduino Analog Pin? Answered

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

Discussions

0
None
blinkyblinky

6 years ago

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.

0
None
buteman

6 years ago

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

For example:
[code]
int pin = 0 ;//analogue pin 0
int value;

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

 void loop()
analogWrite(pin,value)
 }
[/code]
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.
BUT
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.

0
None
txrx

6 years ago

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."

0
None
Bot1398txrx

Answer 6 years ago

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