Digital pins as Analog input pins

Hi everyone,

Is it possible to use Digital pins on Arduino mega 2560 as Analog input for extra pots and buttons ?

Best,
G.

Not easily. Buttons don’t need an analog pin. for a pot you could charge/discharge a cap and see how log it takes to reach the digital threshold.

Search for an 'analog multiplexer IC, maybe a Texas Instruments CD4052BE 4-into-1 multiplexer.
(There may be better ones out there. That was just the first I found when googling)

Then you use a couple of digital IO to control which of the 4 analog inputs is connected to an Analog IO on your Arduino.

74HC4052 not CD4052BE. But the 74HC4051 switches eight inputs.

hdxn:
Is it possible to use Digital pins on Arduino mega 2560 as Analog input for extra pots and buttons ?

I may be jumping to conclusions... but how about move some of your buttons from "analog" pins to the digital ones (those without A prefix)? Buttons are read as digital input anyway.

Most "analog" pins are a digital pin with analog input ability (exceptions are A6/A7 on the Nano/Pro Mini which are analog only; don't know if he Mega has those oddities as well). That's why they work just fine for buttons. Pots otoh indeed do need an anlog input.

Is it possible to use Digital pins on Arduino mega 2560 as Analog input for extra pots

No.

Now the real question is do you want more analogue inputs. The two options are to add and extra A/D but more popular is to add some analogue multiplexing in front of the analogue inputs you have.

Like the two MC14051 chips I used in this project:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Footsteps.html