• Home
  • Blog
  • About
  • Contact
  • Social
  • Affiliate ​Store
2BIT || ! 2BIT
  • Home
  • Blog
  • About
  • Contact
  • Social
  • Affiliate ​Store
2BIT || ! 2BIT

More (than 2) hardware interrupts for Arduino Uno (or nano)!

9/14/2018
when I was building my custom light 4 touch switch panel for my smartHomeDIY I discovered Arduino uno and nano has only 2 hardware interrupts, 
luckly,after searching for a while, I found a blog that helped me to overcome this limitation.
The solution is: pin change interrupts which are supported by the Arduino uno and nano: .

Regular hardware interrupts can be registered for raising or falling or change interrupt, but the pin change interrupts, as their name suggests, are only capable to deliver interrupts when the pin senses a voltage change in any direction, if you need to know which pin was changed you will have to read all pin states (or relevant pins) to know the new state and compare it to the old state (which you have to save on you program.
a small workaround in my case was to register for 2 hardware interrupts and for the other 2 required interrupts I used the pin chagne mechanism, but there are good news, the pin change interrupts are grouped into group of pins 
  • A0 to A5
  • D0 to D7
  • D8 to D13
So I just used different group for each switch and used a counter to ignore the second interrupt - leaving me with a raising interrupt.
Picture
To read more about this topic I recommend the following:
  1. The blog where I found the answer by brainy-bits
  2. The source project for the pin change lib
  3. Arduino documentation here and here and here
  4. And more info on stackexchange
  5. And on the Arduino form and on more here
  6. My open source implementation here
0 Comments



Leave a Reply.

    Categories

    All
    ARDUINO
    ELECTRONICS
    Embedded
    Raspberry Pi
    STM32F103C8T6
    TOOLS

    AliExpress.com Product - Free shipping! Microcontroller learning kit starter and proficient 24 interactive lessons for arduino

    Archives

    January 2019
    September 2018
    August 2018
    February 2018
    January 2018

    RSS Feed

    View my profile on LinkedIn

Do'nt forget

If you like what your read and it helped you trough the development and professional 
​growing 
​journey, please subscribe and share.

get in touch

    Subscribe Today!

Submit