Using D18/SDA & D19/SCL in lieu of A4 & A5

In anticipation of adding an LED display module to an existing UNO R3 project, I find myself running out of I/O (surprise!) but to my shock and amazement I found two pins I didn’t know were there before.

Specifically, I am using a popular I2C LCD that for some reason everyone connects to A4 & A5 for SDA and SCL respectively. Having discovered those two pins D18 and D19, I simply relocated them, and the I2C display works as it always did.

This apparently frees A4 and A5 to be used for other purposes, without affecting the I2C LCD in any way whatsoever.

Is that understanding correct?

That is they key word here

Given that on a Uno R3
A0 is another name for pin 14
A1 is another name for pin 15
A2 is another name for pin 16
A3 is another name for pin 17

Guess what pins A4 and A5 are ?

Have you tried testing continuity between A4/A5 and pins 18/19 ?

No. The SCL/SDA pins up by the USB connector are the same pins on the 328P as A4/A5. They're just brought out in two places. You can verify this yourself by using a multimeter to see that there is continuity between SDA and A4, and SCL and A5. Or by looking at the schematic.

And if that still doesn't do it for you, print out the values of A4 and A5. They're 18 and 19.

Ok, no need to check continuity if the schematic already confirms they're the same. I'll just have to cope.

The reason...

It just lines up nicely.

There is no reason why you should not use the pins marked SDA and SCL but don't try to use A4 and A5 for something different at the same time

It won't be a big deal to use 5V and ground. I'm not running out of them :grinning_face_with_smiling_eyes:

I was equally shocked and amazed I could set A1 and A2 to "high" and "low" respectively, and it worked:

#define VCC A1
#define GND A2
#define DIN A3
#define CS  A4
#define CLK A5

I thought "it can't be that easy" but it was.

Not for long it won't.
You should not use I/O pins as power sources and ground.

When I saw your picture my first thought was "please tell me they're not using I/O pins to power that display".

You might want to look up how much current you can safely draw from an ATmega328P I/O pin, and then look up how much a MAX7219 can draw.

More shock and amazement awaits, and not in a good way.

I'm using I/O pins to power that display :grinning_face_with_smiling_eyes:

It's one reason I'm using a sacrificial board.

The digits in the picture are incrementing as fast as the thing will go. It's been going on 24 hours. I want to see what dies first. The most expensive component set me back about $3.

Ok, I'm done here.

:grinning_face_with_smiling_eyes:

It's my "if it ain't broke, break it" philosophy.

Just set them all to 8 with the decimal point and you won't have to wait so long.

I'll let you know!

That's quite a lot, but I'll let it keep going until it doesn't — or my morbid curiosity is satisfied, whichever comes first.

And what the reason to use a gpio as VCC and gnd?
In contrast to I/O pins, the situation when you "running out of pins vcc and gnd" is impossible.

1. It is not magic that A1 and A2 are working as digtal IO line!

2. On the Arduino UNO R3 board, we have the following legends:
0, ........., 7 8,.........,13; we read them as pin-0 (header pin-0), ......
A0, ......, A5 ; we read them as pin-A0 (header pin-A0), ....

3. After power up reset, the above header pins works as digital input lines. They can be easily as digital output lines by canging their direction as outputs using pinMode() function.

pinMode(A0, OUTPUT);
digitlaWrie(A0, HIGH);

4. A0 - A1 pins are called analog pins to mean that these lines carry exteranl analog sinals for the inernal ADC of the MCU when the ADC Module is enabled.

5. Fig-1 shows the possible alternate signals that A4 and A5 pins can connect for the internal respective modules:

PC4, PC5 ------> Port-C Module
ADC4, ADC5 ----> ADC Module
SDA, SCL ------> I2C Module
PCINT12, PC1NT13 ------> PCINT Module


Figure-1:

but as Vcc and GND it is.

When A1 is HIGH, then it can only source 20 mA; whereas Vcc-pin (5V) of UNO R3 can supply as much as 500 mA (ignoring the current taken by Arduino Board).

Similalry, when LOW is asserted on A1-pin, it can sink only 20 mA; whereas GND-pin can sink 500 mA.

At what voltage?

when LOW is asserted on A1-pin, it can sink only 20 mA;

At what voltage?

At VOH = 4.2 V (min that data sheet guarantees)
At VOL = 0.9 V (max that data sheet guarantees)

4.2-0.9 =3.3V
Useless as a power supply especially if the load current varies.