Hi, I am new to Arduino. I am trying to make a menu that display instruction to the user. They have 5 choices from the keypad. Each choice is just activating a switch, but only once choice is allowed at a time.
The problem is that it is harder than I anticipated. I am getting stuck at displaying the instruction and having the user select. Occasionally the keypad works, but you have to press it multiple times for it to register.
Again I am new to programming and If there is an easier way on doing this, I am open to it. Thanks again.
#include <LiquidCrystal.h>
#include <Keypad.h>
//constants for the number of rows and columns in the LCD
//In my example, I use a 20x4 LCD, thus it has 4 rows and 20 columns
//If you use another LCD, type in the appropriate rows and columns below
const int numRows= 4;
const int numCols= 20;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//initialize the library with the numbers of the interface pins
//For Keypad
const byte ROWS=2;
const byte COLS=3;
char hexaKeys[ROWS][COLS]=
{
{'1','2','3'}, //Row 1 Identifier
{'4','5','6'} //Row 2 Identifier
};
byte rowPins[ROWS]={6,7};
byte colPins[COLS]={8,9,10};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys),
rowPins, colPins, ROWS, COLS);
void setup()
{
lcd.begin(numCols,numRows);
lcd.print("RSFF Direction");
Serial.begin(9600);
}
void loop()
{
LCD();
delay(500);
Meter();
delay(500);
InputPad();
delay(500);
}
void LCD()
{
lcd.setCursor(0,1);
delay(1000);
lcd.print("Choose Charging Method");
delay(4000);
lcd.clear();
//Display Selector Menu
lcd.setCursor(0,0);
delay(1000);
lcd.print("101AC Press 1");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
delay(1000);
lcd.print("APUGen Press 2");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
delay(1000);
lcd.print("Vehicle Press 3");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
delay(1000);
lcd.print("Lift Press 4");
delay(2000);
lcd.clear();
}
void Meter()
{
float input_voltage = 0.0;
float temp=0.0;
int analog_value = analogRead(A0);
input_voltage = (analog_value * 24.00) /1024.00;
if (input_voltage < 0.1)
{
input_voltage=0.0;
}
Serial.print("v= ");
Serial.println(input_voltage);
lcd.setCursor(0, 0);
lcd.print("Voltage= ");
lcd.print(input_voltage);
delay(5000);
;
}
void InputPad()
{
char customKey = customKeypad.getKey();
if (customKey)
{
Serial.println(customKey);
}
}
