0

How to monitor state of 50 Digital Inputs
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How to monitor state of 50 Digital Inputs

by Sergio__ on Mon Oct 08, 2018 11:29 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.

Sergio__
 
Posts: 1
Joined: Mon Oct 08, 2018 11:22 pm

Re: How to monitor state of 50 Digital Inputs

by adafruit_support_bill on Tue Oct 09, 2018 6:03 am

How fast will the inputs be changing and how fast do you need to detect and/or respond to a change?

Using a Mega, it will be much faster to use direct port I/O. That way you can read and compare 8 pins at a time.
https://www.arduino.cc/en/Reference/PortManipulation

Another approach is to use something like the MCP23017. These i2c port expander chips have 16 I/O pins and can generate the equivalent of a pin-change interrupt.
https://www.adafruit.com/product/732

adafruit_support_bill
 
Posts: 70055
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.