Question from a beginner about limits

Hello guys,

I just brought my first arduino last week and started learning somethings, but i still have a question.
Which is the components amount limit? I mean, if i wanna control hundreds of leds and a few dozens of IR sensors in a simple project like Reactive LED Coffee Table - Arduino 2 - YouTube, or more, in a big project like a home automation with dozens of relays, IR sensors, leds, temperature sensors, etc? If components amount is a limitation in both case, how can i procedure?

Thank's.

Obviously if you want to connect large numbers of things you need some way of adding extra "pins" to the Arduino. That is not to diffcult with port expanders.

You also need to be careful not to draw too much current from the Arduino. You should use a separate power supply for the external gadgets.

Each I/O pin can provide about 20mA (40mA absolute max) but I don't think you can draw 20mA from every pin at the same time.

The 5volt pin can provide about 200mA or so of current so it is not suitable for powering motors or large numbers of LEDs.

I guess if you want to control a very large number of things you may find that the code will not run fast enough for what is required. I think it would be very difficult to estimate in advance without timing some test sketches.

...R

Limits is often a balance of requirements. The clockspeed is the ultime limit, it is sort of speed of light barrier.

e.g. no processor can blink leds faster than its clockspeed.
More general, every interaction with a device/component uses time,

  • communication overhead - writing registers, reading status, signals becoming stable, serial output ,...
  • mechanical delays - servo's motors, switches, relays
  • physical delays - factual measurements of a sensor, storing data in memory/flash disks
  • limitations of RAM/FLASH => size of the state-space of a sketch (how much variables and code can it hold)
  • calculation time (executing code)
  • frequency of interaction - (per second)
  • ...

These properties are described in datasheets. But you need to interpret them.

E.g. a relay can switch position in 100 milliseconds does mean you can switch it max 10x per second. But sending the signal to the relay to switch position is just a digitalWrite(pin, HIGH/LOW) which executes in the order of microseconds. So in theory you could control 1 million relays per second. But that is where another limit comes in, The Arduino has not enough pins for 1 million relays, so one could decide to use the I2C bus as that allows up to 120+ chips, each controlling multiple relays. But I2C is much slower than a digitalWrite as you need an addressing scheme, reading/writing registers etc => factor 100-1000 (order of magnitude), dropping the number of relays with a ditto factor.

So in the end it is doing math about what you want, how often, how much times it takes and how all those limits come together in your sketch.

In practice if you want to control hundreds of components it might be good to make a distributed system with multiple (client) controllers, or "local intelligence" so a master processor can control the system on a higher level. It delegates the input and output and processing.

(just some thoughts)