Go Down

Topic: Arduino Menu Help for a Beginner (Read 1 time) previous topic - next topic


Hey all,
First off i apologize if this is in the wrong area, wasnt sure if this goes under Programming Questions or Project Guidance.
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,4 sensor/ live 2 = 5,6,7,8 Sensor).

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

     Live Data
Data Selection - Option A
            |          - Option B
Warning System - Option A - Lower
                               |         - Raise
                           Option B - Lower
                                |         - Raise
                           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.

It would be nice if someone could help point me in the right direction, im kind of not sure where to begin

Here is the code i have at the moment :

Code: [Select]

// 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.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
  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)
  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) {
  } 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

// the loop routine runs over and over again forever:
void loop(void)
  //*** This would be Data Selection Option A ***
  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.print("TempA");             // Temp A
    printTemperature(TempA);        // Temp A
    lcd.print("TempB ");            // Temp B
    printTemperature(TempB);        // Temp B
    lcd.print("TempC");             // Temp C
    printTemperature(TempC);        // Temp C
    lcd.print("V");                 // *** Volts ***
    Voltage();                      // *** Volt Input Monitor ***


It is really difficult to understand "for what you are looking".



You could use M2tklib for LiquidCrystal lib http://code.google.com/p/m2tklib/.

For M2tklib you can select the number of available input buttons. There are "button handlers" for 2, 3, 4, 5 and 6 buttons.
It also supports rotary encoder, multiple buttons at one analog pin and also input from the serial montor.

You can display live data (that means current content of memory values) if you do a regular update of the menu.

M2tklib has a complete reference manual and a lot of tutorials.
Widget elements: http://code.google.com/p/m2tklib/wiki/elref
Function reference: http://code.google.com/p/m2tklib/wiki/fnref
Tutorial 2 for LiquidCrystal with overview on M2tklib: http://code.google.com/p/m2tklib/wiki/t02lc

All examples are carefully tested on my Arduino Uno and Leonardo. As of now i do not know a single example which is not working. Let me know, if you find one.



awesome , thank you

if i have any dramas understanding this or getting it working i will let you know.

cheers  :)


I think MENWIZ is the best and easy menu wizard. must watch, you can post in this thread if find any problem.
I am also working on sun tracking menu with MENUWIZ
Simply...You can't afford me..

Author Of:

Oops..some one gave me Karma...:)

Go Up