Pushbutton Help

Hey guys,
So quick question about pushbuttons...it seems that I have run out of spaces on my digital pins for use. Digital pins 2-13 are in use. Could I have a push button lead to an Analog pin? and instead of having digitalRead I could use analogRead? I know I am a newbie, but thanks guys!

You can use digitalRead there, too.

I use 14 to 19 to reference the analog pins, but I believe A0 to A5 can be used as well.

In fact you can connect several pushbuttons to one analogue pin.

By using a network of resistors you can arrange each pushbutton to put it's own unique voltage on to an analogue pin.

Some Liquid Crystal Display shield, such as this one made by Linksprite, use this technique to connect 5 pushbuttons to one analogue pin.

bemur22:
Could I have a push button lead to an Analog pin?

"Analog" pins A0 to A5 are digital pins.

bemur22:
and instead of having digitalRead I could use analogRead?

You could. but it would be foolish.

Now just so we are clear, pushbuttons should be connected to ground, not Vcc and you use the "INPUT_PULLUP" mode to enable the internal pull-ups in the chip. You can use external pull-up resistors if you feel the need.

What is interesting is that since analog pins A0 to A5 are digital pins, you actually can use the internal pull-up while you read them as analog values - if you need an analog value rather than a digital one.

JohnLincoln:
In fact you can connect several pushbuttons to one analogue pin.
By using a network of resistors you can arrange each pushbutton to put it's own unique voltage on to an analogue pin.
Some Liquid Crystal Display shields ... use this technique to connect 5 pushbuttons to one analogue pin.

Which is a deceptively clever trick used in many consumer devices such as video monitors, tablet computers and MP3 players. Unfortunately it is highly unreliable over time as moisture ingress (particularly when carried on the person) into the "tact"-style pushbuttons causes shunt leakage resistance (and contact degradation may also cause series resistance) causing them to "cipher" and spontaneously actuate or variously not respond or respond as the wrong button.