Analog Pins As Power

I have recently run across the technique of powering analog pins like so:

void setup() {
  pinMode(A4, OUTPUT);
  pinMode(A5, OUTPUT);
  digitalWrite(A4, LOW);
  digitalWrite(A5, HIGH);
}

This supplies 5v through the pins. I am curious if there is a way to supply a lower voltage? I need something between 1.8v and 3.6v for my ADXL335.

That method is using the analog pins as digital pins, and simply turning them on. The analog pins, as analog pins, are input only.

The PWM pins allow you to simulate a lower voltage, if the receiving device accepts PWM signals. The accelerometer is probably not such a device.

The Arduinos have a 3,3V regulator, and can supply 3,3V. Why are you not using that?

I like the convenient placement of the accelerometer as in this tutorial: http://arduino.cc/en/Tutorial/ADXL3xx

Two diodes in series ( = 1.6 to 2V of drop).

runaway_pancake: Two diodes in series ( = 1.6 to 2V of drop).

I'm looking for a software solution but thanks anyways.

Software solution to a voltage drop?

AWOL: Software solution to a voltage drop?

Good point. That's why I'm asking here.

runaway_pancake: Two diodes in series ( = 1.6 to 2V of drop).

That's your best bet. Why do you need a software solution when you could so simply fix it this way?

That's your best bet. Why do you need a software solution when you could so simply fix it this way?

-TECman-

No, the best bet is using the board's 3.3 V rail.

AWOL: No, the best bet is using the board's 3.3 V rail.

That's what I'm doing now.

That's what I'm doing now.

Since that is the right way to power the accelerometer, why are you looking to change it, then?

Also the on-board 3V3 supply is decoupled - using output from a pin you wouldn’t be able to use decoupling easily.

You can create any voltage under 5V using PWM, but you might need to smooth out the square wave in case your device that your powering is fussy. You can do this with a resistor in series then a capacitor pulled to ground.