Turn Arduino Pin into Pin with Interrupt Ability

Hello,

I'm using an arduino nano soldered to a PCB I developped. I have a switch button on the PCB which is connected to Pin8 of the Nano. The problem is that I want the switch to be connected to Pin3 in order to use interrupt ability of the Nano. Instead of printing a new PCB, I would like to find a home-made fix, like using a jumping wire from Pin8 to Pin3 or something. Does someone have an idea?

Thank you,
Freeman

What is Your education, Your programming experience?
I ask because many beginners think that Interrupt is a miracle medicine for almost everything.
Working with real time programming, writing operating systems, executives, I know that interrupts is a way to get into really difficult problems.
Mechanically, bend the Pin3 leg out and don't connect it. Then solder a wire between that leg and the wanted lace on the PCB.

Already mentioned: button debouncing does not fit together with interrupts.

Pin Change INTerrupt PCINT is applicable to (almost) all pins.

2 Likes

:+1:

I would just remove pin 8 from the Nano and solder a thin wire (e.g. wirewrap wire) from pin 8 pad on the PCB to pin 3 on the PCB.

If the Nano is already soldered, I would just use a wire between pin 8 and pin 3 on the PCB as OP already guessed.

1 Like

The only plausible reason to do that is to wake from sleep mode.

Sleep mode is not very useful on a Nano. :roll_eyes:

Basically the nano

  1. receives data from another device at a given frequency
    and
  2. needs to change display mode whenever user presses switch button

Maybe it is not a plausible reason to make use of interrupt ability, then how could I do that?

By using an event-driven approach to programming,
process data if available, check buttons and act if they changed state, easy peasy.

Don't wait for anything, don't use delay.

This approach does not work because the processing of the pixels (128*128) slows down the loop frequency to the point it is not possible to detect any change in button state.

It may not work with the code or code structure you are using now,
but the same argument could be given for a sketch full of delays and for loops.

Divide long running stuff in small segments.

Untangle your current connection between frames and loop iterations.

Post your try, that shows that it does not work.

That would also shed some light on the mysterious

and the type and attachment of the display.

I do not understand anything in your last message. To get into details, I just display numbers on the screen coming from another device, it is something like 5 lines of code using u8g2 library, something really simple. Those 5 lines need more than one second to be executed. How can the nano detect any change in the switch state while the loop is busy for more than 1 second?

You got all the general advices that I know of,
there is no use to talk further, if you don't post the code.

I remembered an additional general advice (from marketing):

It's not a bug, it's a feature. You have to hold the button for more than a second to switch.

If your screen delay is not possible to remove, you will still have the problem even with an interrupt button. Because, you can't do very much inside an interrupt because there, further interrupts are disabled. So a lot of code won't run. Then, are still depending on your main loop to respond to any action that the interrupt produced... hence, the same delay.

So you gain nothing from this approach.

You have to fix your screen handling so it doesn't monopolize the CPU.

Whandall you have everything in your hands to make a constructive answer. I do not need to post the codes, it will make the debate more complicated.
Anyway, thank you everyone for your answers, I will use interrupt ability.

Good luck with your project.

I gain at least one second. When I use interrupt ability, debounce function works as soon as I pressed the button. If not, I have to press the button for more than 1 second to debounce.

I see that you wish to dictate the terms of your enquiry. That will not be received well here. Especially since it contradicts the advice of the forum guidelines that have been in place for many years.

You should read carefully and notice that I don't want to dictate anything, I just tell what I have experienced with and without interrupt ability. And as long as I don't have convincing arguments to bypass interrupt miracle medicine, I will have to use it.

Since you want to talk about forum guidelines, do the guidelines also mention to belittle/diminish OP's goals?

In my first post here as a beginner in electronics, I have been regarded as an OCD person looking for foolish goals. You can also read my other posts, some people here are outrageous.

Fortunately, my project is working fine.

You refused to post your code. It's a standard, and reasonable request. I don't see any examples of belittlement or accusations of OCD here either.

That's true. I made the choice to expose just the relevant part of the problem because I do not want to polluate the forum. My codes are too long to be posted for that very specific concern, it will definitely make the debate more complicated.

If this is not "received well here", I can spend time to isolate that problem and write a new code.

Coming back to the guidelines, I want to insist about the deplorable attitude of some people on that forum. Guidelines should mention to respect OP and his/her goals.

Again, I see no disrespect. Good luck.