Use AREF as digital output

Hey, I have a project where I need to use the AREF pin on the ATMega328 as a digital output. From what I've heard it's definitely possible. The question is - can anyone tell me the code to actually make it happen?

Thanks!

You've heard wrong. The datasheet does not describe any uses for the pin other than as the analog reference...

You might be able to switch it between 1.1v and Vcc by fiddling with the ADMUX register - I don't think it's capable of sourcing or sinking much of any current though, and trying to do so could damage the chip. And of course, you can forget about using analogRead() while doing something like that. This is a bad idea, and I would never do it.

1 Like

ALWAYS consult the data sheet. Here is what the ATmega328 data sheet says about AREF.

VREF can also be measured at the AREF pin with a high impedance voltmeter. Note that VREF is a high
impedance source, and only a capacitive load should be connected in a system.

You can't use it as a digital output.
You can change it between 1.1V, AVcc (3.3V or 5V, however you're powering the chip), and it looks like a floating pin.
See 24.2:
"Internal reference voltages of nominally 1.1V or AVCC are provided On-chip. The voltage reference may be
externally decoupled at the AREF pin by a capacitor for better noise performance."
24.5.2:
"Note that VREF is a high impedance source, and only a capacitive load should be connected in a
system."
and Figure 24-1 and Table 29-15.

So I suppose if you had a weak pulldown resistor, you could use that as a LOW, and then enable 1.1V or AVcc on Aref as a HIGH, but the amount of drive current isn't spec'ed.