battery to analog pin (question)

Hello! Recently i became curious about one thing. Can i plug one cell battery (voltage of which is less than 5 volts) to analog pin and read voltage by using analogRead()? I mean, i know it can be possible, but i'm wondering if battery will burn board or not. Main idea is about checking voltage of battery without using voltage sensor.

Use a 10k resistor in series for protection - this will give reasonably robust protection from over-voltage or polarity reversal without affecting the analogRead() accuracy.

If you connect the battery without a resistor and accidentally have it reversed you'll fry the Arduino and possibly the computer connected to it even... That 10k resistor is a very good investment!

MarkT:
Use a 10k resistor in series for protection - this will give reasonably robust protection from over-voltage or polarity reversal without affecting the analogRead() accuracy.

If you connect the battery without a resistor and accidentally have it reversed you'll fry the Arduino and possibly the computer connected to it even... That 10k resistor is a very good investment!

Thank you for advice! Also i have one more question, can i connet logical pin to another logical pin? Let's say pin D2 have output mode, gives 5 volts (i will use it as voltage source), and pin D3 have input mode, so D2 will be connected with D3 via toggle. Will it be okay or it will make short circuit on board?

WebDweller:
Also i have one more question, can i connet logical pin to another logical pin? Let's say pin D2 have output mode, gives 5 volts (i will use it as voltage source), and pin D3 have input mode, so D2 will be connected with D3 via toggle. Will it be okay or it will make short circuit on board?

I don't know what "via a toggle" means but you can connect two digital pins together provided one of them is definitely in input mode. If you accidentally end up with both pins in output mode that's a disaster waiting to happen.

Steve