Using Analog Pins To Power A Component

I have a project that will be battery powered. I'm looking at powering an accelerometer up and down as-needed using the analog pins to help save the battery. I am using a Pro Mini. As per the Arduino documentation I can't use pins A6 or A7 for power, I can only use pins A0-A5. On the Pro Mini pins A4-A5 are not along the edge of the board. They are inset and don't line up with holes in a breadboard or a standard prototyping board.

I have this simple sketch to test the power. As per this sketch I need 5 pins. I have pins A0-A4 along the edge of the board. I'm wondering if there would be any issues using pin A0 instead of pin A4 and then wiring the ground on the accelerometer to ground on the Arduino. In my tests I read the expected voltage between pin A4 and the Arduino ground. It will be easier to do the soldering when I solder this

int xpin = A2;
int ypin = A3;
int zpin = A4;
int powerpin = A4;
int gnd = A5;



void setup() {

  pinMode(powerpin, OUTPUT);
  pinMode(gnd, OUTPUT);
digitalWrite(powerpin, HIGH);
  digitalWrite(gnd, LOW);
  pinMode(13, OUTPUT);
  // put your setup code here, to run once:

}

void loop() {
  
  // put your main code here, to run repeatedly:

}

How much power are you aiming to draw from a pin ?

Only as much as it takes to power the accelerometer. I could measure the current draw. I got the example from a project using the same accelerometer but I think he was using an Uno in his project.

I could measure the current draw

Please do that

Same '328P processor on both board types. Pins guaranteed for 4.2V @ 20mA. More current than that and the voltage will drop more.

I read 354uA when the ADXL335 is powered using the VCC pin on the Arduino. That is reasonably closed to the specified 350uA in the datasheet.

Then it should be safe to power it from an Arduino pin

Incidentally I don't see why A6 and A7 should not be used as long as you analogWrite 255 to them, but I have never tried it.

You don't have to switch power AND ground to turn something off.

Make sure you don't have Arduino 'outputs' connected to the module when the module if off,
otherwise the module could still be phantom-powered through it's data pins (bad).
Leo..

UKHeliBob:
Incidentally I don't see why A6 and A7 should not be used as long as you analogWrite 255 to them, but I have never tried it.

A6/A7 on a 328 are analogue input only.
Leo..

A6/A7 on a 328 are analogue input only.

You are quite right.

Brain fade on my part