2BIT || ! 2BIT 👨‍💻
  • Home
  • Blog
  • About
  • Social
  • Affiliate ​Store
  • Home
  • Blog
  • About
  • Social
  • Affiliate ​Store

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
AliExpress.com Product - Free shipping 1pcs/lot New FT232RL FT232 USB TO TTL 5V 3.3V Download Cable To Serial Adapter Module For Ardui USB TO 232

Comments are closed.
    AliExpress.com Product - Free shipping! Microcontroller learning kit starter and proficient 24 interactive lessons for arduino
    View my profile on LinkedIn

    Categories

    All
    ARDUINO
    ELECTRONICS
    Embedded
    Raspberry Pi
    STM32F103C8T6
    TOOLS

    RSS Feed

Don't 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 👇