I am trying to make a menu for a monitoring/control system. I am not sure how to make this without interrupting my current code which needs to be monitoring my system at all times to shut off if it reads overload. It is mostly swtich () and case x: stuff. I have looked into attachInteruupt and rotary encoder examples, but none have really helped me figure out how to display a multiple layer menu where I can select to see the system readings as well as edit outputs.

There are a lot of posts here on rotary encoders with LCDs, but I can't seem to find a good skeleton menu code that works well and uses current libraries. My biggest problem right now is making the menu layers without interrupting my monitoring code running in the background.

  • I don't think you should do both tasks on the same microprocessor. Detach the UI an put it on a second processor that sends messages to the control processor over I2C or similar. This way the user can 'accidentally' use the UI is a way the blocks the control processor. Commented Jul 11, 2017 at 15:30

1 Answer 1


you might want to consider timed routines or interrupts.

For timers https://playground.arduino.cc/Code/Timer1 or similar can help.

When using interrupts be sure to be minimalistic because atmegas do not behave well when interrupts take too long to process.

About menus there are several, most of them dynamic and some requiring user display + nav code.

This open-source menu lib (https://github.com/neu-rah/ArduinoMenu) is static, that is good for bigger projects because it stores a lot on flash.

  • (-) you can not change menu at runtime (however it support value fields)
  • (+) requires no user code base
  • (-) setup involves several parts (inputs/output)
  • (+) non blocking polled mode. Just call the poll function on your code loop, the menu will just return if it has no input or output
  • (+) supports a lot of display devices, including i2c lcd
  • (+) supports encoder (interrupts (PCINT) or timed driver)
  • (-) atmega2560 interrupts (PCINT) only on 3 ports, PCINT might require pin mappings (not sure), but if needed the PCINT library examples can print one for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.