Additional interrupts?

So I've been playing with a stupid little project:

http://www.azog.org/blog/?p=88

and am in need of at least one additional interrupt. If you read the blog post above, I basically think I need three, and the Arduino provides two on INT0 and INT1. What would it take to handle an additional interrupt on one of the PCINTxx pins?

I dunno. Your project doesn't sound stupid to me. I think it's a clever idea, and sounds like a lot of fun.

Looking at your app, I don't really see the need for interrupts at all. Are you using them to check your calibration buttons?

You say that you're just counting for the timebase. If so, you should be able to put a calibration button polling routine into your count routine, and jump to a calibration routine if one of the buttons goes active.

However, if I read it wrong, and you really do need three interrupts, I don't know how to do it, either. (I'm sort of new to this Arduino stuff, and haven't learned yet how to dig deeply into the inner workings of the chip.

Perhaps you could diode-or two of your input conditons onto one interrupt.

Good luck!

TJ

Hi and thanks for the reply. The (two) additional buttons will be used to set the time. Press the "minset" button, and an interrupt occurs to set the minutes meter to the desired time, and likewise for the hours button/meter.

I figured to use interrupts over polling because I will want to be able to press them at anytime. However, the app is simple enough that adding a polling routine won't compromise much. I'll have to play with it when I get home and see what I work out.

I have seen some projects which use a single button for multiple functions, like "press" and "press-and-hold". That's probably just a matter of code logic.

Shouldn't be too difficult. Something like this might work:

In setup():

   Initialize I/O pins

   Read millis(), store to current_millis varialble (to detect millis() rollover)

   Add 1000 to millis(), store in next_second var



In loop():

   while(1)
  {

      if (current_millis > millis())     //  check for millis() rollover
          handle_millis_rollover();

      current_millis = millis();

      if (current_millis >= next_second)
      {
         next_second = millis() + 1000L;
         update_time();
      }

      if (test_butons() == 0)     //  test_buttons() returns 0 if one or more buttons are pressed
         handle_button_press();

   }

Again, it's a cool idea, and a good way to make use of the panel meters that might be hanging around your parts boxes, gathering dust.

Have fun with it!

TJ