invalid conversion

Hello all, new day, new problem :s.

trying to get this code to work:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

const byte rows = 4;
const byte cols = 4;

char keys[rows][cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[rows] = {11,10,9,8};
byte colPins[cols] = {7,6,5,4};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("You Pressed:");

}

void loop()
{
char key = keypad.getKey();

if (int(key) != 0) {
lcd.setCursor(16,0);
lcd.print(key);
}
}

Keypad is hooked up and lcd works but when i try to compile i get a error saying:
invalid conversion from 'int' to 't_backlightpol' .

Did a search online first offcourse, that got me to install new libraries but that also don't seem to fix the problem so i'm stuck again :s.

Oh Dear. Look at your code in your post. Did you by any chance use the "Copy for Forum" option in the IDE ? Unfortunately that adds color tags to the code and the code window does not interpret them so you get the mess that you see.

Can you please just do an ordinary Select All and Copy in the IDE and revise the code in your post. It will make it much easier to see what you have done and where the problem is.

ok sorry, just copied code, is this better?

yes, code tags would even be better but OK

seems to be something in the LCD library, I'll check if I can reproduce

reproducable

is this better?

It is now more readable but you did not put it in code tags as you had rightly done the first time. The reason for doing that is to prevent italics being turned on when an array index of i is used, smileys being inserted when their character sequence just happens to occur in code and other side effects.

The code box is also scrollable and has a 1 click method of selecting its contents which helps to provide help by making it easier to copy the code into the IDE or another editor. You nearly had it right with your first post but were not surprisingly mislead by the "Copy for Forum" option.

Now, how about your program ?

LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

The comment does not match the code. Which is right ?

 lcd.init();                      // initialize the lcd 
  lcd.init();

Do you need to initialise the LCD twice ?

Neither is causing your problem but it is better to get obvious things out of the way.

Sorry about the code thing, in the meanwhile i tried another example and that one seems to work.
Thanks for your help and effort !
Ps this sketch worked for me after I re-assigned the display pins.

replace

LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display

with

// LiquidCrystal_I2C (uint8_t lcd_Addr, uint8_t backlighPin, t_backlighPol pol);

LiquidCrystal_I2C lcd(0x3F, 20, POSITIVE);
or
LiquidCrystal_I2C lcd(0x3F, 20, NEGATIVE);

from th lcd lib
// typedef enum { POSITIVE, NEGATIVE } t_backlighPol;

Note the comments are way out of sync with th code ==> code wins!! :wink: