Define analog pin as output

Hello,

Since all the digita pins are in use I want to use the A0 as digital output to light up an IR led.

Normaly for digital pins I first define the pin number (eg Pin8) and then put the led HIGH or LOW:

int led_IR = 8;
pinMode(led_a, OUTPUT);
digitalWrite (led_a, HIGH);

When I try to do the same for analog 0 pin:

int led_IR = "A0";
pinMode(led_a, OUTPUT);
digitalWrite (led_a, HIGH);

It gives an error on the definition of led_IR. Also tried:
const char led_IR = "A0";
But also this is not working.

Who can give me the idea how to declare the constant and use it for the analog pins?

Thanks, Dries

I think the analogue pins carry on from the digital, so AN0 = D14.

If I'm right use

int led_IR = 14;


Rob

Thanks Rob,
You re right, this is working!
BR, Dries :slight_smile:

Or simply don't assign a string to an 'int'

1 Like
int led_IR = "A0";

Is not the same as:

int led_IR = A0;

Which will work since A0 is defined as a macro.

Which will work since A0 is defined as a macro.

A0 is not a macro. From WProgram.h:

const static uint8_t A0 = 14;

(for the non-Mega Arduinos).