Define off ie no backlight, no characters? Post an annotated schematic showing exactly how you have wired it. Be sure to show all connections, power, ground and power sources. Run the I2C scanner and let us know what the results are.
There are 2 buttons. one descreases it, and the other increases it, using 2 buttons and an LCD. for some reason, when i run it, the backlight is on, but no text although i wrote "write a number" so it can be displayed... but the increase button turns it off while being pressed... and the other does nothing
There are many LiquidCrystal_I2C libraries out there.
They are not all the same. Some initialize differently, some have different API functions,
most of them have some issues and pretty much none of them are maintained anymore.
The one in the IDE library manager that now links to the johnrickman git repo is no longer maintained. John, hijacked the library after it was assigned to him and made a wreck of it.
Most of the LiquidCrystal_I2C libraries out there default to having the back light being off after init() or begin() is called.
lcd.backlight() turns on the backlight.
You are calling begin() with 3 parameters, I would not recommend doing this.
The 3rd parameter is for selecting a font size which some LCDs support and some don't. Also, it only works on 1 line displays so it should be being used with a display that is larger than 1 line.
I would recommend using the hd44780 library and the hd44780_I2Cexp i/o class.
It auto locates the i2c address and auto detects the wiring used on the i2c backpack between the PCF8574 chip and the LCD.
This is useful since not all backpacks are wired the same but most libraries are hard coded to work with only one type of backpack.
The hd44780 library can be installed directly from the IDE using the library manager.
The hd44780 library has lots of documentation.
I would highly encourage spending a few minutes going through the documentation to understand how the library uses i/o classes and where to find the i/o class examples.
The documentation can be referenced in the IDE using the Documentation example sketch.
Make sure to have a read of the hd44780_I2Cexp i/o class wiki page.
Install the hd44780 library using the IDE (do not install from a zip file)
Use the hd4480_I2Cexp i/o class.
Run the included I2CexpDiag sketch in the hd44780_I2Cexp i/o class examples.
It will test the I2C connections and the LCD and report any issues it finds.
If I2Cexpdiag reports any issues post them here and we can walk you through how to resolve them.
Well, it's difficult to be sure from that Fritzing style diagram, but it would appear that you have the 3.3V output shorted to ground, and digital input 9 permanently grounded.
Your sketch says pins 2 and 3 are buttons... I think you need to remove all parts, make a drawing, follow the drawing, then write a sketch to match the drawing.
A schematic would give us a much better picture of what you have. I have a feeling you do not know what a schematic is or do not want to draw one. Reference post #1. I could take a SWAG and say some parts are missing, not connected correctly but I cannot be sure.
The 3rd parameter of the constructor is the number lines.
But I was referring to the 3rd parameter of begin().
From my post:
You are calling begin() with 3 parameters, I would not recommend doing this.
Here is the begin() API prototype from LiquidCrystal_I2C.h void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS );
Here is the begin() function declaration from LiquidCrystal_I2C.cpp void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
Here is the setup() function from the OP
void setup() {
lcd.begin(2, 16, 8);
pinMode(buttonUpPin, INPUT_PULLUP);
pinMode(buttonDownPin, INPUT_PULLUP);
lcd.print("Write a number ");
}
Note that begin() is being called with a 3rd parameter of "8".
Also note that backlight() is not called so depending on which LiquidCrystal_I2C library is installed the backlight may not ever be turned on.
The hd44780 library will turn on the backlight as part of begin()