Arduino Forum

Products => Arduino Yún => Topic started by: FilipVDA on Jun 21, 2018, 12:11 pm

Title: Arduino Yun - Digital Output
Post by: FilipVDA on Jun 21, 2018, 12:11 pm

I have a sketch using pin 22 & 23 as Digital Output. On the Analogue header they are A4 and A5.
Everything works fine but I want to add a relay to the setup.

Where can I find the pin layout where pin 22 & 23 are showed ?

I don't know how I got these numbers but it works ... sketch was build more then 1 year ago.

Title: Re: Arduino Yun - Digital Output
Post by: ShapeShifter on Jun 22, 2018, 05:10 pm
I don't understand your question.

You are using digital pins 22 and 23, which are aliases for the analog pins A4 and A5, as you correctly say in your question. But then you ask how do you hook up a relay to them? You can do so by connecting to the A4 and A5 header pins.

When you use digitalWrite() for pins 22 or 23, you are telling the processor to drive pins A4 or A5 as digital outputs. You would hook up a relay to these pins in the same way you would any other digital pins.

Pins 0 through 13 can only be used for digitial input or output. (Some can be used with analogWrite() but they are not real analog outputs, they just use PWM and vary the pulse width, approximating an analog output.)

Pins A0 through A5 can be used as analog inputs, but they can also be used exactly the same as digital pins by using pin numbers 18 (for A0) through 23 (for A5.)