Reading Pins

Hi All,
I do realize that this may be a really dumb question especially being that I'm 3 months and 600 lines of code into this project, but I've just migrated to a new board and am having some really strange issues.

The dumb question is - can I do an analogRead on a digital pin? I have several digital pins 6, 8 & 9 as pinMode Input Pullups. They have button attached to them which are of course also attached to ground. When I first start the board running all three read 1023 and two of them quickly count down to between 490 and 600 the other one seems to stay at 1023 and none of them work. If I change to digitalRead they're all 1's and each will go to zero when pressed. This is fine until the attached battery voltage gets down around 3.85v then sometimes one of them will always be zero and the others are 1's.

I'm going crazy here. Is it me or the $2 Chinese pro mini?

No, you'll get bogus results if you do analogRead() on a digital pin.

As it happens, analogRead() of 0~7 will read pins A0~A7. Numbers between 7 and A0 (I think that's defined as 14, I forget what the first analog pin is) will return god-knows-what. Only the analog pins are connected to the ADC.

How is everything wired? Is the pro mini connected to power through the serial adapter?

Pro minis have A0-7
Lowering the voltage is abnormal.
If this is a 5 volt board, keep the voltage in range.


You can do an analogRead() on a digital pin but don’t expect it to return sensible values.

Is yours a 5V or 3.3V Pro Mini ?

Awesome responses. Thank You All!!

I'm using a 3V but have a 5v to toy with next. How in the heck was all of this working with zero problems on the Adafruit 3v pro trinket?? Im analogReading digital pins and visa versa on the adafruit board, switch everything over to this incredibly inexpensive ebay pro mini and have crazy problems.

I'm powering with a 3.7 - 4.2v lion battery connected to RAW. I've noticed that if the serial is connected the readings get even stranger.

How's it wired?? Like a plate of spaghetti. I have 3 buttons, 1 oled, 1 battery, 1 battery charger, a dc boost converter, two pwm's, and 3 voltage dividers. I'm telling you; spaghetti! It's great though, well it was until I migrated to this new board.


EDIT** so I've just ctrl+z'd my code back a ways and apparently I wasn't doing analogRead on a digital pin before. That was something new I did late last night I guess since the digtalRead's are returning either 0 or 1 and doing so seemingly randomly. Not sure if that's because of a "low" battery or not. Although I don't think that 3.85v on a 3.7v lion is really all that low...

I've just ctrl+z'd my code back a ways

You would be much better off saving your code with a new name before making significant changes rather than relying on Ctrl/Z. That way you have a copy of the code at various stages, can open more than one version at a time and copy/paste between them.