PinChange Interrupt library - is usage still recommended?

Greetings

I will be using an Uno in my project but I will need a minimum of 8 interrupts, I a aware that the UNO only have 2.

During research I came across the following library : PinChange Interrupt. (https://www.brainy-bits.com/make-any-arduino-pin-an-interrupt-pin/).

However the code was last updated in 2015.

Question:
Is the library still a viable option for having multiple interrupts

Regards

However the code was last updated in 2015.

So?
This is not Linux where things older than a few weeks are obsolete.

Is the library still a viable option for having multiple interrupts

Yes

I would not use the library but just write the appropriate ISR; see e.g. Arduino Playground - PinChangeInterrupt.

Be aware that the Uno only has one 8-bit port (D0..D7) so you might have to spread the pins over two or three ports (and ISRs).

I can’t see how that invalidates the libiary?

One thing you have to watch is if you use this feature and some other libiary is using it like software serial.

Thank you for the replies.

We should ask the question: why do you believe you need 8 interrupts? What's the project, what's connected to those pins, and what will the Arduino be busy doing at the moment when an interrupt occurs?

The project will control stage prompt lights - i.e. actor informs co-coordinator he/she is ready, and then a go signal is given.
So currently the idea is as follows:
Per station
2 Led's (3 states Red: Flashing, Steady Green: Steady)
Station has 2 buttons: Read, Reset
Controller has 2 buttons Go, Reset (same as station)
So to control each station I will need 3 interrupts, and 2 Led (5 pins)

There is 19 pins available on the UNO therefore I will be able to control 3 stations (15 pins)
So my math was out I need 9 interrupts

Hope this answer the question why I need so many interrupts.

Regards

Hope this answer the question why I need so many interrupts.

No, it is really raising more questions. Interrupts are rarely needed for reading button switches. You need non-blocking code which is always looking at the buttons with digitalRead() hundreds of times per second in loop().

What is supposed to happen when an interrupt triggers? What is the ISR code?

If the code which runs after a button press or interrupt is sensed is "blocking" with the use of delay(), while loops, or long "for" statments, the code really needs to be recrafted.

My intuition tells me you need non blocking code rather than 9 interrupts.

Cattledog

Thank you for the questions.

I was thinking of just using the loop but the tutorials I am following mention the use of interrupts to monitor the button pressing. It could also be that I am understanding the instructions wrong.

I am a raw beginner - knows something of electronics, knows coding

Ok what is supposed to happen

C = Controller
A = Actor
S = Prompt Station

C: Set station to warn (Red LED Flash) - not sure yet how I will do this
S: Flashing Red
A: When ready Press Ack Button
S: Steady Red
C: Press Go Button
S: Steady Green
A: does whatever s/he is supposed to do
S: After about 3 to 4 seconds all LED's go off.

If issue crops up that requires a abort (for example another actor blocks a door) then either C or A press reset (Red LED Flash).

I will be building 3 prompt stations.

So if I understand your guidance - just put a bunch of if statements in the loop and check the required pins.
For example
if S is in a warning state - then check the pin that will change the state to ack and so on

It's as I suspected, and that's why I asked the question. Your application has absolutely no need of interrupts, they are not needed at all for detecting button presses. Those tutorials you saw must have been written by inexperienced people, if they think this is what interrupts are for. Forget interrupts, they are a distraction!

PaulRB

Thank you for the feedback.

So if I understand your guidance - just put a bunch of if statements in the loop and check the required pins.
For example
if S is in a warning state - then check the pin that will change the state to ack and so on

Sounds about right, but I think you will want to see if any button has become pressed, rather than is pressed. You want to detect button state changes(i.e. not pressed to pressed) not state. You need to compare the current button reading to the previous reading.

You can use if statements or switch case. You may want to develop the code as a "state machine". I think it is cleanest to read all the buttons at the start of loop() and take actions depending on what was pressed. That is you have a distinct input block and an output block in the code.

You may need to use debounce on the buttons, but it's not clear from your description if that's really required.

How will the controller communicate with the prompt stations?

For the flashing red and the 3-4 second period you will need to use the non blocking millis() timers shown in the "blink without delay" examples and the tutorials here Demonstration code for several things at the same time - Project Guidance - Arduino Forum and here http://forum.arduino.cc/index.php?
topic=503368.0

Good luck with your project, and when you have some code, come back with any questions. I would recommend the "Programming" section rather than the "LED's and multiplexing".

Cattledog

Thanks for the guidance.
For debounce - still deciding between code and hardware (555 timer circuit)
The communications will most likely be multi-core cable.

Other questions will be done in the programming section

555 timers for button debouncing make the circuit more complicated and can be replaced with a couple of extra lines of code.

I doubt if you need any debouncing for the application. Ignore it until you know you need it. 90% of the time it is not necessary and I can’t see it being necessary here.