How to monitor state of 50 Digital Inputs

For the discussion of Arduino related topics.

Moderator: phalanx

Post Reply
Posts: 1
Joined: Mon Oct 08, 2018 8:31 pm

How to monitor state of 50 Digital Inputs

Post by Sergio__ » Mon Oct 08, 2018 8:34 pm

Hello. Good day.

I have a specific project need and I spent the past couple of days searching on forum, blogs, etc and I'm still not clear if that's feasible to do with Arduino or not.

I need to monitor the state of ~50 digital inputs and trigger an action when any of the pin changes either from 0 to 1 or from 1 to 0, pretty much the same as pin state interrupt works, only difference is that I need to "listen" to ~50 pins, instead of just a couple. I must be able to identify what pin triggered the action and what was the change (0->1 or 1->0).

My initial idea is to use a MEGA 2560 and have a group of 50 "if" statements on the main loop comparing the previous state or each pin (stored in individual variables) with the current one and triggering the corresponding action if something changed.

I'd like to hear from the experts here what would be a more elegant or smarter/faster way to accomplishing this.

I'm eager to receive your feedback.

Thank you.

Posts: 303
Joined: Sat Nov 11, 2017 2:39 am

Re: How to monitor state of 50 Digital Inputs

Post by paulvha » Tue Oct 09, 2018 9:36 am

I would look at These boards can handle up to 16 inputs. They connect over I2C to the processor and each has it's own I2C address. The interesting part is that each board has an INT-line which will trigger low when any of the 16 inputs change. The processor only has to monitor the 4 INT - inputs and then perform an action to read the status from the right board. Much easier code to program, maintain and in case of issues to debug.
Regards, Paul

Post Reply