Skip to main content
edited tags
Link
Michel Keijzers
  • 13k
  • 7
  • 40
  • 58
Source Link

How to monitor state of 50 Digital Inputs

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.