Grounding the pins vs Not reading them


I know this might be a silly stupid question, but it just popped in my head so thought would get thoughts on this from community.

while searching for solutions for floating pins issue, i noticed that all suggest to ground unused / floating pins.
I tried to skip reading from these pins in the code, and it works great, so I am confused

Cant we just skip reading from the unused pins, instead of grounding them. are there any disadvantages / problems using above method.


The general rule with all CMOS inputs is never leave them floating. Several things
can happen if floating, including oscillation and shoot-through currents, both causing
much higher current drain from the supply (milliamps rather than nanoamps for the
input buffer).

However the ATmega microcontrollers use some hysteresis on the inputs to mitigate
this. You can also turn on the internal pull-ups on unused pins to prevent them

If you want to run at micropower (ATmega on a low power board using sleep mode),
then you should ensure no pins can float to ensure sleep-mode power is properly low.

Atmel's recommendation is to leave unused pins as inputs with the internal pullup enabled. In the IDE, use:
pinMode (pinX, INPUT_PULLUP);

Then if your code accidentally drives the pin, it won't be grounded and be damaged.

@CrossRoads & @MarkT : thanks for the detailed explanations, such information helps newbiee's like to grasp and understand the whole thing in better way.