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]