Hi everyone.I’m having a problem linking the LiquidCrystal_I2C.h and the keypad.h . If i delete everything about the keypad, the LCD works well and emulating the keypad with serial comunication it works well. On the other hand, if i delete everything about the LCD and emulate it with serial monitor the keypad works well. The problem is that when i use the following code which links both libraries, the keypad library stops working and doesn´t recognise the button pressed.Some digits are not recognised and others are, but not in the button in which they are supposed to be. I’d be very grateful if anybody could help me.
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C dsp(0x20,2,1,0,4,5,6,7);
#include <Keypad.h>
const byte rows=4,columns=4;
char boton,botones[row][columns]={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPin[rows]={13,12,11,10},colPin[columns]={9,8,7,6};
Keypad teclado= Keypad(makeKeymap(botones),filPin,colPin,rows,columns);
unsigned long anterior = 0;
void setup() {
dsp.begin(16,2);
dsp.setBacklightPin(3,POSITIVE);
dsp.setBacklight(HIGH);
escribir(0,0,0,"Hello");
escribir(1,0,1,"world");
delay(3000);
a=0;
b=0;
}
void writing (int x,int y, int z, char text[16]){
if (x==0){
dsp.clear();}
dsp.setCursor(y,z);
dsp.print(text);}
char reading(){
boton=teclado.getKey();
return boton;
}
void start(){
inicio:
while(reading() == NO_KEY){
unsigned long tiempo = millis();
if(tiempo - anterior >= 2000) {
anterior = tiempo;
switch (a){
case 0:
writing(0,0,0,"Seleccione:");
a=1;
break;
case 1:
writing(0,0,0,"G: Girasol");
writing(1,0,1,"M: Maiz O: Otros");
a=0;
break;}}}
a=0;
switch (boton){
case 'A':
writing(0,0,0,"Selected:");
writing(1,0,1,"A");
delay(1500);
operacion(0);
break;
case 'B':
writing(0,0,0,"Selected");
writing(1,0,1,"B");
delay(1500);
operacion(1);
break;
case 'C':
writing(0,0,0,"Selected");
writing(1,0,1,"C");
delay(1500);
operacion(2);
break;
default:
writing(0,0,0,"Nothing");
delay(1500);
goto inicio;
}}
void loop(){
start();}