#include <Keypad.h>
#include "LiquidCrystal.h"
LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
String buf = "";
String memory = "";
int um = 1;
const byte LINHAS = 4; //4 linhas
const byte COLUNAS = 4; //4 colunas
char keys[LINHAS][COLUNAS] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'S','0','H','D'}
};
byte rowPins[LINHAS] = {9, 8, 7, 6};
byte colPins[COLUNAS] = {5, 4, 3, 2};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, LINHAS, COLUNAS );
String v_passcode="";
void setup()
{
Serial.begin(9600);
lcd.begin(16,4);
lcd.home();
lcd.setCursor(0,0);
lcd.print("A --> Resistencia");
lcd.setCursor(0,1);
lcd.print("B --> Corrente");
lcd.setCursor(4,2);
lcd.print("C --> Potencia");
lcd.setCursor(4,4);
lcd.print("* --> Menu");
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY){
if (key == 'A'){
buf = "";
resistencia();
}
else if (key == 'B'){
buf = "";
corrente();
}
else if (key == 'C'){
buf = "";
potencia();
}
}
}
void resistencia() {
int i = 0;
char key2 = keypad.getKey();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Resistencia = ");
lcd.setCursor(0, 1);
lcd.print("Tensao = ");
lcd.setCursor(4, 2);
lcd.print("Corrente = ");
lcd.setCursor(4, 4);
lcd.print("Potencia = ");
while(i == 0){
char key2 = keypad.getKey();
if(key2 == 'H'){
}
if(key2 == 'S'){
break;
}
lcd.setCursor(0, 0);
lcd.print("Resistencia = ");
if (key2 != NO_KEY){
memory = key2;
buf += key2;
lcd.print(buf);
}
}
setup();
}
void corrente() {
int i = 0;
char key2 = keypad.getKey();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Corrente = ");
lcd.setCursor(0, 1);
lcd.print("Tensao = ");
lcd.setCursor(4, 2);
lcd.print("Potencia = ");
while(i == 0){
char key2 = keypad.getKey();
if(key2 == 'H'){
}
if(key2 == 'S'){
break;
}
lcd.setCursor(0, 0);
lcd.print("Corrente = ");
if (key2 != NO_KEY){
memory = key2;
buf += key2;
lcd.print(buf);
}
}
setup();
}
void potencia() {
int i = 0;
char key2 = keypad.getKey();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Potencia = ");
lcd.setCursor(0, 1);
lcd.print("Tensao = ");
lcd.setCursor(4, 2);
lcd.print("Corrente = ");
while(i == 0){
char key2 = keypad.getKey();
if(key2 == 'H'){
}
if(key2 == 'S'){
break;
}
lcd.setCursor(0, 0);
lcd.print("Potencia = ");
if (key2 != NO_KEY){
memory = key2;
buf += key2;
lcd.print(buf);
}
}
setup();
}