I was wondering if there are a way to do a menu system for arduino UNO using buttons and without libraries.

I tried to do it by myself but the code was too long and heavy.

I don't want full code, just a pseudo-code idea and how does it works.

I know there are libraries that to this, but I want to practise C++.


1 Answer 1


Interactive menus are certainly not a "simple" task. That is why people use libraries.

Whatever you try you will end up with complex code - either long winded with lots of duplication, or somewhat cryptic with lots of pointers, arrays, and structures. Not an easy task for a beginner in C++.

How I would set about it would involve the following things:

  1. A structure that defines a menu entry, including pointers to one of: sub-menu array, numeric variable (including max/min limits), option array, function to execute.
  2. Arrays of the above structure to define each menu
  3. Array or linked list of "breadcrumbs" through the menu to track where you are and go back up properly
  4. Functions to display and navigate the menu arrays on an LCD.

All of that uses fairly advanced C coding techniques, especially when it comes to managing all the pointers, etc.

The "simpler", though more long winded way, would be to write individual functions for each menu and sub-menu, but that would make your program incredibly long and prone to have errors when duplicating (copy/paste) code.

  • agree, i would add that all those structures probably will end up taking a lot of ram.. and sooner or later you will end up wanting them on flash memory, bringing even more complexity to your code, but yes, go for it! its a good chance to later appreciate a library and still learn a lot of c++ :D
    – neu-rah
    Mar 3, 2017 at 19:37

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.