element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduino Lcd Menu Help
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 4 replies
  • Subscribers 401 subscribers
  • Views 676 views
  • Users 0 members are here
Related

Arduino Lcd Menu Help

Former Member
Former Member over 13 years ago

Hey all,

I'm having difficulty trying to set up a menu with my arduino and lcd screen.

what im trying to do, is have a display page that shows live data all the time, if enter button is held for 5 secs or more enter menu where you can change some values for a warning led or select which set of live data to display (i.e. live 1 = 1,2,3 sensor/ live 2 = 4,5,6,7 Sensor).

 

I imagine a structure like so: you always showing live data, it shows real time temp, etc..

 

(enter button not held for 5 secs or more)

Live Data displayed.

 

(if enter button is held for 5 secs or more enter the menu below)

    

    

Data Selection   - Option A  ( change live data display temp sensors 1-3 + voltage )

            |                  |

            |              Option B ( change live data display temp sensors 4-7 )

            |

Warning System - Option A - Lower   (Temp sensor A lower warning value)

                               |         - Raise   (Temp sensor A raise warning value)

                           Option B - Lower   (Temp sensor B lower warning value)

                                |         - Raise  (Temp sensor B raise warning value)

                           Option C - Lower

                                         - Raise

 

 

if not sure how to do this exactly, i know i need Menubackend which i have, i haven't found many tutorials on it or examples, and of what examples i could find, i could never get it working, it would either not work in the menu or it would work in the menu but show a static show of the data, not showing live data. So im a little bit confused. I'd Ideally like to be able to do this with 3 buttons, left right and enter, however enter has multiple functions, press long out of menu enters the menu, press short out of menu does nothing, press short in menu selects item, press long in menu goes to previous.

 

 

*little update*

 

i've been searching but the most i've been able to make sense of is http://www.coagula.org/content/pages/tutorial-manage-menu-and-lcd-display-arduino

 

even still, i can setup all the menu like i want, i can get the menu to function per say, however it only shows you a snapshot when you use data selction options, or the live data overrides the menu.

 

i wish i saved the code so i could post what i tried and didnt get working,  when i did try it it seemed like a lot of extra data, going from 3kb to 12kb.

 

i dont expect nor want anyone to write the code for me, i'm just hoping someone can point me in the right direction be it a youtube tutorial or anything that i can read and get a better understanding of it all, all this programming / coding is new to me but im willing to learn.

 

here is the code i do have anyway, it just shows live temp data in the loop without a menu.

 

[code]

// include the library code

#include <LiquidCrystal.h>

#include <OneWire.h>

#include <DallasTemperature.h>

// Data wire is plugged into pin 6 on the Arduino

#define ONE_WIRE_BUS 6

 

// Setup a oneWire instance to communicate with any OneWire devices

OneWire oneWire(ONE_WIRE_BUS);

 

// Pass our oneWire reference to Dallas Temperature.

DallasTemperature sensors(&oneWire);

 

// Assign the addresses of your 1-Wire temp sensors.

DeviceAddress TempA = { 0x28, 0xAA, 0x80, 0x2C, 0x04, 0x00, 0x00, 0xBA };

DeviceAddress TempB = { 0x28, 0xE9, 0x80, 0x2C, 0x04, 0x00, 0x00, 0x96 };

DeviceAddress TempC = { 0x28, 0x67, 0xA3, 0x2C, 0x04, 0x00, 0x00, 0xD9 };

 

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

#define LCD_WIDTH 16

#define LCD_HEIGHT 2

 

// Assigning Pun Allocations and Names : (analog = A0,A1..) (digital = 0,1,2,3..)

const int FactoryOFF = 13;

//const int WarningLED = 5; //off for testing  pins d2,d3,d4,d5 for button array testing

const int analogInput = A0;

 

//*** Changing and Stored values

//*** Volt Monitor

float VOut = 0.0;

float VIn = 0.0;

float R1 = 2000.0;     // *** resistance of R1 ***

float R2 = 1000.0;     // *** resistance of R2 ***

int value = 0;

 

// the follow variables is a long because the time, measured in miliseconds,

// will quickly become a bigger number than can be stored in an int.

long interval = 1000;           // interval at which to blink (milliseconds)

 

//*** the setup routine runs once when you press reset:

void setup()

{

  //*** set the resolution to 10 bit (good enough?)

  sensors.begin();               

  sensors.setResolution(TempA, 10); 

  sensors.setResolution(TempB, 10);

  sensors.setResolution(TempC, 10);

 

  //*** set up the LCD's number of rows and columns:

  lcd.begin(LCD_WIDTH, LCD_HEIGHT,1);          

  lcd.clear();                                  // Start with a blank screen

  lcd.setCursor(0,0);                           // Set cursor to column 0, row 0

  lcd.print("  Initializing  ");                // Print 'Initalizing' to the LCD.

 

  delay(500);                                   // Wait 5 seconds, Lcd Flash Sequence

  lcd.noDisplay();

  delay(500);

  lcd.display();

  delay(500);

  pinMode(FactoryOFF, OUTPUT);                  // Initialize the factory led as a digital output.

  digitalWrite (FactoryOFF, LOW);               // Keep it off

  pinMode(analogInput, INPUT);                  // Initialize A0 as Input (Voltage Monitor)

   

  lcd.noDisplay();

  delay(500);

  lcd.display();

  delay(500);                                   // .5 Second Delay before lcd clear

  lcd.clear();                                  // Clear screen after setup run

}

 

void printTemperature(DeviceAddress deviceAddress)

{

float tempC = sensors.getTempC(deviceAddress);

  if (tempC == -127.00) {

      lcd.print("Er");

  } else {

          lcd.print(tempC,0);       // (tempc,x) x = is you variable point, i.e ,0 is no decimal, ,1 is 1 decimal,etc,

         }

}

 

void Voltage()

{

  value = analogRead(analogInput);

  unsigned long currentMillis = millis();

  VOut = (value * 4.81) / 1024.0;

  VIn = VOut / (R2/(R1+R2));

  VIn = VIn,2;                      // *** ,x statement modifies the decimal place

  lcd.print(VIn);

}

 

// the loop routine runs over and over again forever:

void loop(void)

{

  delay(250);                       // .250 second delay to slow things down

  //LCD Menu Item, Set Locations And What Readings.

    sensors.requestTemperatures();  // just before this menu runs, read temps

    lcd.setCursor(0,0);            

    lcd.print("TempA");             // Temp A

    lcd.setCursor(6,0);            

    printTemperature(TempA);        // Temp A

    lcd.setCursor(0,1);            

    lcd.print("TempB ");            // Temp B

    lcd.setCursor(6,1);            

    printTemperature(TempB);        // Temp B

    lcd.setCursor(9,0);            

    lcd.print("TempC");             // Temp C

    lcd.setCursor(13,0);           

    printTemperature(TempC);        // Temp C

    lcd.setCursor(9,1);           

    lcd.print("V");                 // *** Volts ***

    lcd.setCursor(11,1);         

    Voltage();                      // *** Volt Input Monitor ***

}

 

[/code]

  • Sign in to reply
  • Cancel
Parents
  • Workshopshed
    0 Workshopshed over 13 years ago

    Here's an example that looks for a long button press

     

    http://volatilebit.com/electronics/minor-arduino/item/11-press-hold-switch-arduino

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Reply
  • Workshopshed
    0 Workshopshed over 13 years ago

    Here's an example that looks for a long button press

     

    http://volatilebit.com/electronics/minor-arduino/item/11-press-hold-switch-arduino

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 13 years ago in reply to Workshopshed

    Awesome , thank you.

     

    I manage to use that example to correct alot of my loop function, however now the loop bounces between many if's inside it to do various things and i was able to do enter as short and enter as long (.5sec vs 3 secs, different functions)

     

    Now its all working super and i've got a slightly couple of little bugs, but hopefully i can sort them out with too much drama.

     

    I didnt know how much was involved in this coding/programming, i did do a little back at uni days but nothing like this.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Workshopshed
    0 Workshopshed over 13 years ago in reply to Former Member

    If you've got lots of Ifs then you might want to switch those to "switch"

     

    http://arduino.cc/en/Reference/SwitchCase

     

    If it's even more complex than that you might want to look at using a state machine

     

    http://playground.arduino.cc/Code/FiniteStateMachine

    http://www.skorks.com/2011/09/why-developers-never-use-state-machines/

     

    I've also found working with the Arduino a bit of a flashback to my earlier days, when I was coding for the ZxSpectrum

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 13 years ago in reply to Workshopshed

    Dont get me wrong, my code loop isnt just an giant if statement, i have void Display1, 2 etc.. that are my display functions showing the sensors live data,Im not 100% sure if im correct but from what i understood void was a function more or less.

     

    With switchcase i imagine its similar to the code below. The navigation control for the menu, after tinkering around with that example i posted in my original post, i got alot more understanding of how this works sorta lol.

     

    My issue with learning code is im unsure of definitions , like i understand in menubackend.h(after looking in menubackend file in notepad) the moveDown etc... commands control movement of the menu you setup in the code eariler on, but things like currentMenu , if i didnt see an example of it i wouldnt know how to use or to even try to use.

    That being said i did very little programming with VB and C+ back in the day, those skills are mostly forgotten except for knowing that pretty much most things can work of if statements.

     

    I know i do have 1 bug in my code error, it is minor and is a pain, as after every choice of which live data you select, it briefly displays the menuRoot, then goes to the live data even with lcd.noDisplay(); etc... but something i should be able to figure out.

     

    [CODE]

    void navigateMenus() {

      MenuItem currentMenu=menu.getCurrent();

     

      switch (lastButtonPushed){

        case buttonPinEnter:

          if(!(currentMenu.moveDown())){                       // if the current menu move was Down, then enter will use the item.

            menu.use();

          }else{                                                          // otherwise, action to moveDown.

            menu.moveDown();

           }

          break;

        case buttonPinEsc:

        if(!(currentMenu.moveRight())){                         // if the current menu move was Right, then esc will move left if pressed next.

            menu.moveLeft();                                       // action to moveLeft

          }else if(!(currentMenu.moveDown())){              // if the current menu move was Down, then esc will move up if pressed next.

            menu.moveUp();                                        // action to moveUp

          }else {  //otherwise, return to the root menu

            menu.toRoot();

           }

          break;

        case buttonPinRight:

          menu.moveRight();

          break;    

        case buttonPinLeft:

          menu.moveLeft();

          break;    

      }

    [/CODE]

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube