How many inputs at once?

Hello, i was just wondering how many inputs could use at once on arduino (lets say i have put already 3 pots), and how many digital inputs could work without "ghosting" and other problems?

lets say i have put already 3 pots), and how many digital inputs could work

The pots are analog inputs.

Of course analogRead() only reads one pin at a time so you can't read multiple pins "at once".

You can use 'em all, but you need some extra time (some microseconds) between reads. There is only one (multiplexed) analog-to-digital converter and it needs time to "settle". It's fairly standard practice to read the pin twice and ignore (or overwrite) the 1st reading. That should give it enough time to settle.

You can read the digital pins as fast as the processor runs, and there are port commands to read more than one pin with a single instruction.

This will be dictated by the required responsiveness and how fast the inputs change - usually this isn't an issue unless your requirements for are particularly demanding on that front. See the read/write benchmarks thread in microcontrollers section - someone timed the pin functions for common boards - the common cases where it becomes an issue (aside from poorly written sketches that use delay() inappropriately) are when there are aggressive requirements for quickly reading analog channels, or when you're processing multiple things that change really fast, and even using interrupts, you miss events (ex, because the other ISR was running when the event occurred, but the condition has gone away by the time that ISR finishes, leaving the next ISR confused. IIRC this was happening to someone a little while back who was trying to read multiple rotary encoders on motor shafts at once). But these are all rather extreme cases - you generally don't run into limits like this under typical arduino use cases.

Note that with direct port write/read, you can do digital read/write operations much faster than the arduino wrapper (ie, within a couple of processor cycles) - the arduino wrapper spends extra time to convert the arduino pin number to the port and bit within that port.

Hello to both of you,

Doug, when you say read the values twice and ignore the first reading, do you mean reading the same value in the next command line, without any delay? And of course based on the second reading decide how to proceed? This is The first time I have heard of this. Thank you very much.

Yours,

Mike

Mikeb1970: when you say read the values twice and ignore the first reading, do you mean reading the same value in the next command line, without any delay? And of course based on the second reading decide how to proceed?

Yes. That, and a capacitor (10-100n) from analogue pin to ground, are common ways to deal with ghost charges from previously reading a different analogue input and high impedance sources. Leo..