Pages: [1]   Go Down
Author Topic: LCM1602 IIC V1 Backlight not Working  (Read 1301 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a LCM1602 IIC V1 and am using the code below, however, the backlight is not turning on. Am I missing something here? Everything else with the LCD seems to work.

Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

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


const int pot_pin = 0;
const int dir_pin = 5;
const int mag_pin = 3;
float Vout;
int mag = 0;
int voltage;

void setup()
{
  Serial.begin(28800);
  lcd.init();                      // initialize the lcd
  pinMode(pot_pin,INPUT);
  pinMode(dir_pin, OUTPUT);
  pinMode(mag_pin, OUTPUT);
  lcd.clear();
  lcd.backlight();
}

void loop()
{
//mag = map(analogRead(pot_pin),0,1023,0,255);
if ( mag < 1023 ){mag+=2;}
if(mag > 1023){mag = 0;}
Vout =19*mag/1023;
delay(15);
Serial.println(Vout);
digitalWrite(dir_pin,HIGH);
analogWrite(mag_pin, mag);

lcd.setCursor(0,0);
lcd.print("Voltage:");
lcd.setCursor(10,0);
lcd.print(Vout);
}
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, I am using the Ardiuno Nano Pro, anyway it could be something to do with this?
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2766
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The type of arduino board should not affect backlight control.

The only way to know for sure what is going on is to know 2 things:
- how the backlight is wired up
- how is the library trying to drive the backlight.

Neither of these pieces of information can be derived from
the information provided so far.
What makes things not quite so simple is that there are many i2c lcd boards
out there that have the same or similar names but are not wired up the
same way. So just knowing the name of the board or what is printed
on it doesn't necessarily help.

In order to help you fix things, we need more information.



For the first, a schematic of the board is key.
If the vendor did not provide you with a schematic
you will need to look at the the
board and derive how the backlight circuitry is wired.
The key information here is which PCF8574 pin (if any) is being
used to control the backlight.
Note that some boards do not have or support backlight control
from the PCF8574 chip. They either don't support backlight control at all
or use a hardware jumper.
Those that do do have backlight control in s/w
can use positive or negative logic to turn the backlight
on depending on which type of transistor is used.
Some boards use a h/w jumper but can still control the backlight
in s/w.

The next piece of information is what library you are using.
Nearly all the libraries out there are hard coded to a particular board design.
If the board design is different from what is in the library things won't work
correctly.
Making it a bit more challenging is that many i2c lcd libraries are all called the same or use the same
header file name and constructor name so just seeing the example doesn't indicate
which library is being used.
You are not using it, but my preference is this one:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
because it allows the library to configured for any board design.
The key with this one is that you must know how all the PCF8574 pins
are wired and the polarity of the backlight because you put
the information in the lcd constructor to configure the library.

--- bill


Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 63
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tied two pins together on the backside labeled "LED", backlight now functions
Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2766
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Functions as in lcd.backlight() and lcd.noBacklight() work or
it now just turns on?

Logged

Pages: [1]   Go Up
Jump to: