0

i've totally done everything i could,but when i run my arduino uno with my 16*2 lcd (with i2c) . it has a higher brightness on the top and a lower one in the bottom. ive even tried putting example codes but my arduino totally freaks out, starting to change it's backlight . i cant even use lcd.print . i had tried just to adjust my lcd with a ldr , this is the code:

    // Include Wire Library for I2C
#include <Wire.h>
// Include NewLiquidCrystal Library for I2C
#include <LiquidCrystal_I2C.h>
int ldr;
int sensor=0;
int lcdb=5;

// Define LCD pinout
const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

// Define I2C Address - change if reqiuired
const int i2c_addr = 0x3F;

LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

void setup()
{

  // Set display type as 16 char, 2 rows
  lcd.begin(16,2);
  Serial.begin(9600);
  lcd.setCursor(0,1);
  lcd.print("hello world");
  lcd.setCursor(0,0);
  delay(1000);
  lcd.print("hello world");


} 
void loop()
{
  int ldr=analogRead(sensor);
  ldr=map(ldr, 0, 1023, 0,255);
  delay(1000);
  analogWrite(lcdb,ldr);

}
  • Please also provide a wiring diagram, so that we can see, how everything is connected – chrisl Apr 28 '20 at 11:47
  • What library are you using, because LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE); doesn't make sense for the library I found. Also the code seems to imply the backlight is connected to pin 3 on the I2C device, but also to pin 5 of the UNO. – Gerben Apr 28 '20 at 13:06
  • i used the new liquidcrystal library – pertifiedchicken Apr 30 '20 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.