Can I use digital pins as analog?

Hello.

I Was just wondering. Can I use digital pins as analog?

I have done some research and it says that I could do it changing "pins_arduino.h" or something like that. Any way, I am not sure how to do that.

Thanks!!!

Do not cross-post. Other thread removed.

JEAR1109: I Was just wondering. Can I use digital pins as analog?

You mean use digital pin input (not A0 etc) for analog to digital conversion?

Can I use digital pins as analog?

No.

You misunderstood what you read.

xy problem?

It seems you just want more analogue pins than your current Arduino has.
That can be ‘fixed’ with an analogue muxer.
Leo…

The irony of it all is of course that analogWrite() isn't doing much when used with analog pins, while analogRead() can't do anything with digital pins.

If you want more analog inputs, your choices are a indeed a mux or analog extension boards such as the ADS1115 (which your read over I2C).

wvmarle: The irony of it all is of course that analogWrite() isn't doing much when used with analog pins

Oh geez... yeah. Maybe need to just bite the bullet one day... and formally change the name of that function.

Or at least introduce an alias... PWMWrite() or so, and change all tutorials on the site to use that name with the mention that there's an older alias for the same function... It's probably too late to completely remove analogWrite() now.

Mm, yeah! I like the idea of a name change and an alias to stay backwards compatible. Think I might start doing that (alas the other way around) just to make it clear :D

as for the initial question.

although you cannot put a varialbe voltage on a digital pin and read it as an analog voltage. you can use an R/C to charge a cap and then count how long it takes to charge the cap. Had to use this in the old days before Analog inputs were common on chips.

R/C TIME Basic Stamp

so, a digital pin be connected to a pulse frequency that is created by an analog voltage.