Pessoal,
Venho pesquisando e tentando fazer um menu no LCD, já consegui escrever o que eu quero no LCD. O problema está na tentativa de fazer um menu que tem duas opções e dentro quero alterar o valor pelos botoes up, down e select.
MENU
Temperatura --> Mudar valor entre 0 a 100
Umidade --> Mudar valor entre 0 a 100
Meu kaypad retorna sinais Select, Left, Up, Down, Right, gostaria de navegar nas opções, entrar com select mudar o valor com up e down e confirmar gravando o valor na variável com select e em seguida voltar pra tela principal.
Mas como disse, estou tentando fazer e está me faltando aquela luz que brilha, já pesquisei alguns exemplos mas são muito complexos, e fogem do que eu quero.
Alguém pode ajudar ?
Segue meu código já feito:
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// put your setup code here, to run once:
//Set the characters and column numbers.
lcd.begin(16, 2);
PrintTelaPrincipal();
}
void loop() {
// put your main code here, to run repeatedly:
//Call the main menu.
mainMenu();
}
void mainMenu() {
//State = 0 every loop cycle.
int posicao = 0;
//Refresh the button pressed.
int x = analogRead (0);
//Set the Row 0, Col 0 position.
lcd.setCursor(0,0);
//Check analog values from LCD Keypad Shield
if (x < 100) {
lcd.setCursor(0,1);
lcd.clear();
//testando se teclado funciona no loop
//lcd.print("Right");
//delay(1000);
//PrintTelaPrincipal();
posicao = 5;
} else if (x < 200) {
//Up
posicao = 1;
} else if (x < 400){
//Down
posicao = 2;
} else if (x < 600){
//Left
posicao = 4;
} else if (x < 800){
//Select
posicao = 3;
}
}
void PrintTelaPrincipal() {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("00 dias restante");
lcd.setCursor(0,1);
lcd.print("T 37.5 UR 62.0%");
}